Thu, 15 Jun 2023 16:18:03 +0300
Refactor, make selecting elements from the model select the corresponding line from the editor as well
cmake_minimum_required(VERSION 3.0) project(LDForge VERSION 1.0) set(COPYRIGHT "Copyright (C) 2013 - 2022 Teemu Piippo") string(TOLOWER ${PROJECT_NAME} TARGET_NAME) set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/CMake") include(cotire) set(OpenGL_GL_PREFERENCE GLVND) find_package(Qt6 COMPONENTS Core Widgets OpenGL UiPlugin OpenGLWidgets) if (Qt6_FOUND) message(NOTICE "-- Using Qt6") find_package(Qt6 REQUIRED COMPONENTS Core5Compat) # Unfortunately "Qt::UiPlugin" doesn't seem to work so let's resolve # it here instead... add_library(QtUiPlugin ALIAS Qt6::UiPlugin) else() message(NOTICE "-- Qt6 not found, using Qt5 instead") find_package(Qt5 5.5 REQUIRED COMPONENTS Core Widgets OpenGL UiPlugin) add_library(QtUiPlugin ALIAS Qt5::UiPlugin) endif() find_package(OpenGL REQUIRED) find_package(GLEW REQUIRED) find_package(GLM REQUIRED) set(CMAKE_AUTOMOC ON) set(CMAKE_AUTOUIC ON) set(CMAKE_AUTORCC ON) include_directories(${CMAKE_CURRENT_BINARY_DIR}) include_directories(${GLM_INCLUDE_DIR}) add_definitions(-DQT_NO_KEYWORDS) source_group(${PROJECT_NAME} REGULAR_EXPRESSION "src/.+\\.(cpp|h|ui)") 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 -Wpedantic -Wunused") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-implicit-fallthrough") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-noexcept-type") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wformat-nonliteral -Wnonnull -Wnull-dereference -Winfinite-recursion -Wuninitialized -Wmissing-noreturn") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wshadow") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wundef -Wmissing-field-initializers") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wcast-qual -Wcast-align -Wcast-function-type -Wconversion") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wmissing-declarations -Wdate-time") endif() if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wcovered-switch-default -Wextra-semi -Wgnu -Wmicrosoft") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Woverloaded-virtual -Wsometimes-uninitialized -Wstring-concatenation -Wstring-conversion -Wsuggest-override") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wsuggest-override -Wundefined-func-template -Wundefined-reinterpret-cast") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wuninitialized-const-reference -Wunreachable-code -Wunreachable-code-break -Wunreachable-code-return") endif() # Pass some CMake variables down to the source code add_definitions(-DCMAKE_PROJECT_NAME="${CMAKE_PROJECT_NAME}") add_definitions(-DTARGET_NAME="${TARGET_NAME}") add_definitions(-DCMAKE_PROJECT_VERSION="${CMAKE_PROJECT_VERSION}") add_definitions(-DCOPYRIGHT="${COPYRIGHT}") add_definitions(-DCMAKE_CXX_COMPILER_ID="${CMAKE_CXX_COMPILER_ID}") add_definitions(-DCMAKE_CXX_COMPILER_VERSION="${CMAKE_CXX_COMPILER_VERSION}") add_definitions(-DCMAKE_CXX_FLAGS="${CMAKE_CXX_FLAGS}") add_definitions(-DCMAKE_SYSTEM_PROCESSOR="${CMAKE_SYSTEM_PROCESSOR}") add_definitions(-DCMAKE_SYSTEM="${CMAKE_SYSTEM}") add_definitions(-DCMAKE_BUILD_TYPE="${CMAKE_BUILD_TYPE}") add_subdirectory(widgets) set(SOURCE_FILES src/bezier_curve.cpp src/colors.cpp src/documentmanager.cpp src/geometry.cpp src/ldrawalgorithm.cpp src/ldrawsyntaxhighlighter.cpp src/libraries.cpp src/inputvertices.cpp src/invert.cpp src/main.cpp src/mainwindow.cpp src/messagelog.cpp src/model.cpp src/openedmodel.cpp src/parser.cpp src/polygoncache.cpp src/triangulate.cpp src/uiutilities.cpp src/version.cpp src/vertexmap.cpp src/gl/basicshaderprogram.cpp src/gl/compiler.cpp src/gl/partrenderer.cpp src/layers/axeslayer.cpp src/layers/edittools.cpp src/layers/gridlayer.cpp src/settingseditor/keyboardshortcutseditor.cpp src/settingseditor/librarieseditor.cpp src/settingseditor/settingseditor.cpp src/types/boundingbox.cpp src/ui/circletooloptionswidget.cpp src/widgets/colorindexinput.cpp src/widgets/colorselectdialog.cpp ) set(HEADER_FILES src/basics.h src/bezier_curve.h src/circularprimitive.h src/colors.h src/documentmanager.h src/geometry.h src/inputvertices.h src/invert.h src/ldrawalgorithm.h src/ldrawsyntaxhighlighter.h src/libraries.h src/mainwindow.h src/messagelog.h src/model.h src/modelsubwindow.h src/openedmodel.h src/parser.h src/polygoncache.h src/settings.h src/triangulate.h src/typeconversions.h src/uiutilities.h src/version.h src/vertexmap.h src/gl/basicshaderprogram.h src/gl/common.h src/gl/compiler.h src/gl/partrenderer.h src/layers/axeslayer.h src/layers/edittools.h src/layers/gridlayer.h src/settingseditor/keyboardshortcutseditor.h src/settingseditor/librarieseditor.h src/settingseditor/settingseditor.h src/types/boundingbox.h src/ui/circletooloptionswidget.h src/widgets/colorindexinput.h src/widgets/colorselectdialog.h thirdparty/earcut.h ) set(FORM_FILES src/about.ui src/mainwindow.ui src/settingseditor/librarieseditor.ui src/settingseditor/settingseditor.ui src/ui/circletool.ui src/widgets/colorselectdialog.ui src/widgets/colorindexinput.ui ) set(CMAKE_AUTOUIC_SEARCH_PATHS src/ui) set(QRC_FILE resources.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}") qt_add_resources(QRC_SOURCE ${QRC_FILE}) qt_wrap_ui(FORMS_HEADERS ${FORM_FILES}) add_executable(${TARGET_NAME} WIN32 ${SOURCE_FILES} ${HEADER_FILES} ${QRC_FILE} ${QRC_SOURCE} ${FORMS_HEADERS} ${OTHER_FILES} ) set_source_files_properties(${HEADER_FILES} PROPERTIES HEADER_FILE_ONLY TRUE) set_source_files_properties(${QRC_FILE} PROPERTIES HEADER_FILE_ONLY TRUE) set_source_files_properties(${OTHER_FILES} PROPERTIES HEADER_FILE_ONLY TRUE) set_target_properties(${TARGET_NAME} PROPERTIES AUTOMOC 1) target_link_libraries(${TARGET_NAME} PRIVATE Qt::Core) target_link_libraries(${TARGET_NAME} PRIVATE Qt::Widgets) target_link_libraries(${TARGET_NAME} PRIVATE Qt::OpenGL) target_link_libraries(${TARGET_NAME} PRIVATE ${OPENGL_LIBRARIES}) target_link_libraries(${TARGET_NAME} PRIVATE ${GLEW_LIBRARIES}) target_link_libraries(${TARGET_NAME} PRIVATE ${WIDGETLIB}) if (Qt6_FOUND) target_link_libraries(${TARGET_NAME} PRIVATE Qt6::Core5Compat) target_link_libraries(${TARGET_NAME} PRIVATE Qt6::OpenGLWidgets) endif() cotire(${TARGET_NAME}) add_custom_target(linelength ALL COMMAND python3 "${CMAKE_SOURCE_DIR}/tools/linelength.py" ${SOURCE_FILES} ${HEADER_FILESl} WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}) add_dependencies(${TARGET_NAME} linelength) add_custom_target(indentlevel ALL COMMAND python3 "${CMAKE_SOURCE_DIR}/tools/indentlevel.py" ${SOURCE_FILES} ${HEADER_FILESl} WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}) add_dependencies(${TARGET_NAME} indentlevel) # 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(${TARGET_NAME} revision_check) install(TARGETS ${TARGET_NAME} RUNTIME DESTINATION bin)