CMakeLists.txt

Wed, 15 Jun 2022 12:17:29 +0300

author
Teemu Piippo <teemu.s.piippo@gmail.com>
date
Wed, 15 Jun 2022 12:17:29 +0300
changeset 223
ce81db996275
parent 221
e28f89b8ccdf
child 232
8efa3a33172e
permissions
-rw-r--r--

Use Mapbox's ear clipping algorithm to handle drawing any simple polygon

project(ldforge)
cmake_minimum_required(VERSION 2.8.12)
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/CMake")
#include(cotire)
set(OpenGL_GL_PREFERENCE GLVND)
find_package(Qt5Widgets REQUIRED)
if (Qt5Widgets_VERSION VERSION_LESS 5.5.0)
	message(FATAL_ERROR "Qt5 version 5.5 required")
endif()
find_package(Qt5Core REQUIRED)
find_package(Qt5OpenGL REQUIRED)
find_package(Qt5Network REQUIRED)
#find_package(Qt5LinguistTools REQUIRED)
find_package(GLM REQUIRED)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTORCC ON)
find_package(OpenGL REQUIRED)
include_directories(${QT_INCLUDES} ${CMAKE_CURRENT_BINARY_DIR})
include_directories(${GLM_INCLUDE_DIR})
add_definitions(-DQT_NO_KEYWORDS)
source_group("LDForge" REGULAR_EXPRESSION "src/.+\\.(cpp|h|ui)")

set (LDFORGE_SOURCES
	src/colors.cpp
	src/document.cpp
	src/documentmanager.cpp
	src/geometry.cpp
	src/ldrawalgorithm.cpp
	src/libraries.cpp
	src/invert.cpp
	src/main.cpp
	src/model.cpp
	src/parser.cpp
	src/polygoncache.cpp
	src/uiutilities.cpp
	src/version.cpp
	src/vertexmap.cpp
	src/gl/axesprogram.cpp
	src/gl/basicshaderprogram.cpp
	src/gl/compiler.cpp
	src/gl/gridprogram.cpp
	src/gl/partrenderer.cpp
#	src/gl/vertexprogram.cpp
	src/settingseditor/keyboardshortcutseditor.cpp
	src/settingseditor/librarieseditor.cpp
	src/settingseditor/settingseditor.cpp
	src/types/boundingbox.cpp
#	src/ui/canvas.cpp
	src/ui/multiplyfactordialog.cpp
	src/ui/objecteditor.cpp
	src/widgets/colorbutton.cpp
	src/widgets/colorindexinput.cpp
	src/widgets/colorselectdialog.cpp
	src/widgets/doublespinbox.cpp
	src/widgets/matrixeditor.cpp
	src/widgets/vec3editor.cpp
)
set (LDFORGE_HEADERS
	src/basics.h
	src/colors.h
	src/document.h
	src/documentmanager.h
	src/functional.h
	src/geometry.h
	src/invert.h
	src/ldrawalgorithm.h
	src/libraries.h
	src/model.h
	src/parser.h
	src/polygoncache.h
	src/ring.h
	src/settings.h
	src/typeconversions.h
	src/uiutilities.h
	src/version.h
	src/vertexmap.h
	src/algorithm/earcut.h
	src/gl/axesprogram.h
	src/gl/basicshaderprogram.h
	src/gl/common.h
	src/gl/compiler.h
	src/gl/gridprogram.h
	src/gl/partrenderer.h
#	src/gl/vertexprogram.h
	src/settingseditor/keyboardshortcutseditor.h
	src/settingseditor/librarieseditor.h
	src/settingseditor/settingseditor.h
	src/types/boundingbox.h
#	src/ui/canvas.h
	src/ui/multiplyfactordialog.h
	src/ui/objecteditor.h
	src/widgets/colorbutton.h
	src/widgets/colorindexinput.h
	src/widgets/colorselectdialog.h
	src/widgets/doublespinbox.h
	src/widgets/matrixeditor.h
	src/widgets/vec3editor.h
)
set (LDFORGE_FORMS
	src/mainwindow.ui
	src/settingseditor/librarieseditor.ui
	src/settingseditor/settingseditor.ui
	src/ui/multiplyfactordialog.ui
	src/ui/objecteditor.ui
	src/widgets/colorselectdialog.ui
	src/widgets/colorindexinput.ui
	src/widgets/matrixeditor.ui
	src/widgets/vec3editor.ui
)

set(LDFORGE_LOCALES
	locale/fi.ts
	locale/sv.ts
)

set (LDFORGE_OTHER_FILES
)

set(LDFORGE_RESOURCES ldforge.qrc)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
include_directories("${PROJECT_BINARY_DIR}")
include_directories("${PROJECT_BINARY_DIR}/src")
include_directories("${PROJECT_SOURCE_DIR}/src")

# Translations
#qt5_create_translation(QM_FILES ${LDFORGE_SOURCES} ${LDFORGE_HEADERS} ${LDFORGE_FORMS} ${LDFORGE_LOCALES})
#add_custom_target(translations ALL DEPENDS ${QM_FILES})
add_custom_target(resources ALL DEPENDS ${LDFORGE_RESOURCES})

if (NOT MSVC)
	if ("${CMAKE_BUILD_TYPE}" STREQUAL "Debug" OR "${CMAKE_BUILD_TYPE}" STREQUAL "RelWithDebInfo")
		set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DDEBUG")
	endif()
	set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra")
	set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-implicit-fallthrough")
	set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-noexcept-type")
endif()
qt5_add_resources(LDFORGE_QRC ${LDFORGE_RESOURCES})
qt5_wrap_ui(LDFORGE_FORMS_HEADERS ${LDFORGE_FORMS})

# Move languages.qrc into the build directory to bake the .qm-files into LDForge
# so that they don't have to be shipped separately
# https://stackoverflow.com/a/34798124
# https://gist.github.com/giraldeau/546ba5512a74dfe9d8ea0862d66db412
set(LANGUAGES_QRC "languages.qrc")
configure_file(${LANGUAGES_QRC} ${CMAKE_CURRENT_BINARY_DIR} COPYONLY)
qt5_add_resources(LDFORGE_QM_RC_FILE ${CMAKE_CURRENT_BINARY_DIR}/${LANGUAGES_QRC})
set_source_files_properties(${LDFORGE_LOCALES} PROPERTIES HEADER_FILE_ONLY TRUE)

add_executable(ldforge WIN32
	${LDFORGE_SOURCES}
	${LDFORGE_HEADERS}
	${LDFORGE_RESOURCES}
	${LDFORGE_QRC}
	#${LDFORGE_QM_RC_FILE}
	${QM_FILES}
	${LDFORGE_FORMS_HEADERS}
	${LDFORGE_OTHER_FILES}
)

set_source_files_properties(${LDFORGE_HEADERS} PROPERTIES HEADER_FILE_ONLY TRUE)
set_source_files_properties(${LDFORGE_RESOURCES} PROPERTIES HEADER_FILE_ONLY TRUE)
set_source_files_properties(${LDFORGE_OTHER_FILES} PROPERTIES HEADER_FILE_ONLY TRUE)
set_target_properties(ldforge PROPERTIES AUTOMOC 1)
target_link_libraries(ldforge Qt5::Widgets Qt5::Network Qt5::OpenGL ${OPENGL_LIBRARIES})
add_dependencies(ldforge resources)
#cotire(ldforge)

add_custom_target(linelength ALL
	COMMAND python3
		"${CMAKE_SOURCE_DIR}/tools/linelength.py"
		${LDFORGE_SOURCES}
		${LDFORGE_HEADERS}
	WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
add_dependencies(ldforge linelength)

# Collect the current hg revision into hginfo.h
add_custom_target(revision_check ALL
	COMMAND python3 "${CMAKE_SOURCE_DIR}/tools/updaterevision.py" --cwd "$(CMAKE_SOURCE_DIR)" hginfo.h
	WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
add_dependencies(ldforge revision_check)

install(TARGETS ldforge RUNTIME DESTINATION bin)

mercurial