Mon, 27 Jun 2022 01:28:04 +0300
use project name more in cmakelists
CMakeLists.txt | file | annotate | diff | comparison | revisions | |
widgets/CMakeLists.txt | file | annotate | diff | comparison | revisions |
--- a/CMakeLists.txt Mon Jun 27 01:09:18 2022 +0300 +++ b/CMakeLists.txt Mon Jun 27 01:28:04 2022 +0300 @@ -22,10 +22,10 @@ include_directories(${CMAKE_CURRENT_BINARY_DIR}) include_directories(${GLM_INCLUDE_DIR}) add_definitions(-DQT_NO_KEYWORDS) -source_group("LDForge" REGULAR_EXPRESSION "src/.+\\.(cpp|h|ui)") +source_group(${PROJECT_NAME} REGULAR_EXPRESSION "src/.+\\.(cpp|h|ui)") add_subdirectory(widgets) -set (LDFORGE_SOURCES +set(SOURCE_FILES src/colors.cpp src/documentmanager.cpp src/geometry.cpp @@ -57,7 +57,7 @@ src/widgets/colorindexinput.cpp src/widgets/colorselectdialog.cpp ) -set (LDFORGE_HEADERS +set(HEADER_FILES src/basics.h src/circularprimitive.h src/colors.h @@ -96,7 +96,7 @@ src/widgets/colorindexinput.h src/widgets/colorselectdialog.h ) -set (LDFORGE_FORMS +set(FORM_FILES src/mainwindow.ui src/settingseditor/librarieseditor.ui src/settingseditor/settingseditor.ui @@ -106,23 +106,22 @@ src/widgets/colorindexinput.ui ) -set(LDFORGE_LOCALES +set(LOCALE_FILES locale/fi.ts locale/sv.ts ) -set (LDFORGE_OTHER_FILES +set (OTHER_FILES ) set(CMAKE_AUTOUIC_SEARCH_PATHS src/ui) -set(LDFORGE_RESOURCES ldforge.qrc) +set(QRC_FILE 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}") -add_custom_target(resources ALL DEPENDS ${LDFORGE_RESOURCES}) if (NOT MSVC) if ("${CMAKE_BUILD_TYPE}" STREQUAL "Debug" OR "${CMAKE_BUILD_TYPE}" STREQUAL "RelWithDebInfo") @@ -143,32 +142,31 @@ 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() -qt_add_resources(LDFORGE_QRC ${LDFORGE_RESOURCES}) -qt_wrap_ui(LDFORGE_FORMS_HEADERS ${LDFORGE_FORMS}) +qt_add_resources(QRC_SOURCE ${QRC_FILE}) +qt_wrap_ui(FORMS_HEADERS ${FORM_FILES}) -add_executable(ldforge WIN32 - ${LDFORGE_SOURCES} - ${LDFORGE_HEADERS} - ${LDFORGE_RESOURCES} - ${LDFORGE_QRC} - ${LDFORGE_FORMS_HEADERS} - ${LDFORGE_OTHER_FILES} +add_executable(${PROJECT_NAME} WIN32 + ${SOURCE_FILES} + ${HEADER_FILES} + ${QRC_FILE} + ${QRC_SOURCE} + ${FORMS_HEADERS} + ${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 PRIVATE Qt::Core) -target_link_libraries(ldforge PRIVATE Qt::Widgets) -target_link_libraries(ldforge PRIVATE Qt::OpenGL) -target_link_libraries(ldforge PRIVATE ${OPENGL_LIBRARIES}) -target_link_libraries(ldforge PRIVATE ${GLEW_LIBRARIES}) -target_link_libraries(ldforge PRIVATE ldforgewidgets) -add_dependencies(ldforge resources) +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(${PROJECT_NAME} PROPERTIES AUTOMOC 1) +target_link_libraries(${PROJECT_NAME} PRIVATE Qt::Core) +target_link_libraries(${PROJECT_NAME} PRIVATE Qt::Widgets) +target_link_libraries(${PROJECT_NAME} PRIVATE Qt::OpenGL) +target_link_libraries(${PROJECT_NAME} PRIVATE ${OPENGL_LIBRARIES}) +target_link_libraries(${PROJECT_NAME} PRIVATE ${GLEW_LIBRARIES}) +target_link_libraries(${PROJECT_NAME} PRIVATE ${WIDGETLIB}) if (Qt6_FOUND) - target_link_libraries(ldforge PRIVATE Qt6::Core5Compat) - target_link_libraries(ldforge PRIVATE Qt6::OpenGLWidgets) + target_link_libraries(${PROJECT_NAME} PRIVATE Qt6::Core5Compat) + target_link_libraries(${PROJECT_NAME} PRIVATE Qt6::OpenGLWidgets) endif() add_custom_target(linelength ALL @@ -177,12 +175,12 @@ ${LDFORGE_SOURCES} ${LDFORGE_HEADERS} WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}) -add_dependencies(ldforge linelength) +add_dependencies(${PROJECT_NAME} 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) +add_dependencies(${PROJECT_NAME} revision_check) -install(TARGETS ldforge RUNTIME DESTINATION bin) +install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION bin)
--- a/widgets/CMakeLists.txt Mon Jun 27 01:09:18 2022 +0300 +++ b/widgets/CMakeLists.txt Mon Jun 27 01:28:04 2022 +0300 @@ -1,10 +1,12 @@ -qt_wrap_ui(LDFORGEWIDGETS_FORMS +set(WIDGETLIB "${PROJECT_NAME}widgets" PARENT_SCOPE) +set(WIDGETLIB "${PROJECT_NAME}widgets") +qt_wrap_ui(WIDGETS_FORMS vec3editor.ui multiplyfactordialog.ui matrixeditor.ui ) -add_library(ldforgewidgets SHARED +add_library(${WIDGETLIB} SHARED colorbutton.cpp colorbutton.h designerplugins.cpp @@ -17,21 +19,21 @@ vec3editor.h multiplyfactordialog.cpp multiplyfactordialog.h - ${LDFORGEWIDGETS_FORMS} + ${WIDGETS_FORMS} ) get_target_property(UIPLUGIN_INCLUDES QtUiPlugin INTERFACE_INCLUDE_DIRECTORIES) -target_include_directories(ldforgewidgets PUBLIC "${UIPLUGIN_INCLUDES}") -target_include_directories(ldforgewidgets PUBLIC "${CMAKE_SOURCE_DIR}") -target_include_directories(ldforgewidgets PUBLIC "${CMAKE_CURRENT_BINARY_DIR}") -target_link_libraries(ldforgewidgets Qt::Widgets) -set_target_properties(ldforgewidgets PROPERTIES AUTOMOC 1) +target_include_directories(${WIDGETLIB} PUBLIC "${UIPLUGIN_INCLUDES}") +target_include_directories(${WIDGETLIB} PUBLIC "${CMAKE_SOURCE_DIR}") +target_include_directories(${WIDGETLIB} PUBLIC "${CMAKE_CURRENT_BINARY_DIR}") +target_link_libraries(${WIDGETLIB} Qt::Widgets) +set_target_properties(${WIDGETLIB} PROPERTIES AUTOMOC 1) get_target_property(QT_QMAKE_EXECUTABLE Qt::qmake LOCATION) execute_process(COMMAND ${QT_QMAKE_EXECUTABLE} -query QT_INSTALL_PLUGINS OUTPUT_VARIABLE QT_INSTALL_PLUGINS OUTPUT_STRIP_TRAILING_WHITESPACE ) -install(TARGETS ldforgewidgets LIBRARY DESTINATION lib) -install(TARGETS ldforgewidgets +install(TARGETS ${WIDGETLIB} LIBRARY DESTINATION lib) +install(TARGETS ${WIDGETLIB} LIBRARY DESTINATION ${QT_INSTALL_PLUGINS}/designer )