Thu, 05 Mar 2020 15:58:35 +0200
grid autorotation
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(GLUT 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(${GLUT_INCLUDE_DIR}) include_directories(${GLM_INCLUDE_DIR}) set (LDFORGE_SOURCES src/colors.cpp src/document.cpp src/documentmanager.cpp src/geometry.cpp src/libraries.cpp src/invert.cpp src/main.cpp src/mainwindow.cpp src/model.cpp src/modeleditcontext.cpp src/parser.cpp src/uiutilities.cpp src/version.cpp src/gl/compiler.cpp src/gl/gridprogram.cpp src/gl/partrenderer.cpp src/linetypes/comment.cpp src/linetypes/conditionaledge.cpp src/linetypes/edge.cpp src/linetypes/errorline.cpp src/linetypes/metacommand.cpp src/linetypes/object.cpp src/linetypes/quadrilateral.cpp src/linetypes/subfilereference.cpp src/linetypes/triangle.cpp src/settingseditor/keyboardshortcutseditor.cpp src/settingseditor/librarieseditor.cpp src/settingseditor/settingseditor.cpp src/types/boundingbox.cpp src/ui/canvas.cpp src/widgets/colorbutton.cpp ) set (LDFORGE_HEADERS src/basics.h src/colors.h src/document.h src/documentmanager.h src/functional.h src/geometry.h src/header.h src/invert.h src/libraries.h src/main.h src/mainwindow.h src/maths.h src/model.h src/modeleditcontext.h src/parser.h src/ring.h src/uiutilities.h src/utility.h src/version.h src/gl/common.h src/gl/compiler.h src/gl/gridprogram.h src/gl/partrenderer.h src/linetypes/comment.h src/linetypes/conditionaledge.h src/linetypes/edge.h src/linetypes/errorline.h src/linetypes/metacommand.h src/linetypes/object.h src/linetypes/quadrilateral.h src/linetypes/subfilereference.h src/linetypes/triangle.h src/settingseditor/keyboardshortcutseditor.h src/settingseditor/librarieseditor.h src/settingseditor/settingseditor.h src/types/boundingbox.h src/ui/canvas.h src/widgets/colorbutton.h ) set (LDFORGE_FORMS src/document.ui src/mainwindow.ui src/settingseditor/librarieseditor.ui src/settingseditor/settingseditor.ui ) set(LDFORGE_LOCALES locale/fi.ts locale/sv.ts ) set (LDFORGE_OTHER_FILES src/configurationoptions.txt ) set(LDFORGE_RESOURCES ldforge.qrc) set(CMAKE_CXX_STANDARD 17) 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} ${CMAKE_BINARY_DIR}/configuration.cpp ) 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}) target_link_libraries(ldforge ${GLUT_LIBRARIES}) add_dependencies(ldforge resources) cotire(ldforge) add_custom_target (config_collection ALL COMMAND python3 "${CMAKE_SOURCE_DIR}/tools/configcollector.py" --header ${CMAKE_BINARY_DIR}/configuration.h --source ${CMAKE_BINARY_DIR}/configuration.cpp --sourcedir ${CMAKE_SOURCE_DIR}/src ${CMAKE_SOURCE_DIR}/src/configurationoptions.txt WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}) add_dependencies(ldforge config_collection) set_source_files_properties (${CMAKE_BINARY_DIR}/configuration.cpp PROPERTIES GENERATED TRUE) set_property(SOURCE configuration.cpp PROPERTY SKIP_AUTOGEN ON) # 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)