CMake target renaming to avoid C++ errors with `-`

This commit is contained in:
Shaun Reed 2023-01-15 16:23:26 -05:00
parent 195a4ef30d
commit cfefc49c53
4 changed files with 37 additions and 32 deletions

View File

@ -24,8 +24,8 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
if(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
add_compile_options(/wd4131 /wd4127)
if(MSVC)
add_compile_options(/WX:NO /wd4131 /wd4127)
endif()
################################################################################

View File

@ -29,7 +29,7 @@ install(
DESTINATION lib/cmake/Qtk
)
install(
EXPORT qtk-export
EXPORT qtk_export
FILE QtkTargets.cmake
NAMESPACE Qtk::
DESTINATION lib/cmake/Qtk
@ -43,6 +43,11 @@ set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Qt OpenGL 3D graphics library.")
set(CPACK_PACKAGE_HOMEPAGE_URL "https://github.com/shaunrd0/qtk")
set(CPACK_SOURCE_IGNORE_FILES build;install;\.git;\.github;\.idea)
set(CPACK_PACKAGE_DIRECTORY packages/)
# OSX
set(CPACK_BUNDLE_NAME Qtk)
#set(CPACK_BUNDLE_PLIST )
#set(CPACK_BUNDLE_ICON )
if(WIN32)
set(CPACK_SOURCE_GENERATOR ZIP)
else()

View File

@ -23,16 +23,16 @@ set(
toolbox.h
treeview.h
)
qt_add_library(qtk-plugin-library STATIC)
qt_add_library(qtk_plugin_library STATIC)
target_sources(
qtk-plugin-library PRIVATE
qtk_plugin_library PRIVATE
"${QTK_PLUGIN_LIBRARY_SOURCES}"
"${QTK_PLUGIN_LIBRARY_HEADERS}"
)
target_link_libraries(qtk-plugin-library PUBLIC Qt6::UiPlugin qtk-library)
target_link_libraries(qtk_plugin_library PUBLIC Qt6::UiPlugin qtk_library)
install(
TARGETS qtk-plugin-library
TARGETS qtk_plugin_library
BUNDLE DESTINATION lib
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib/static
@ -40,7 +40,7 @@ install(
)
install(
TARGETS qtk-plugin-library
TARGETS qtk_plugin_library
BUNDLE DESTINATION "${QTK_PLUGIN_LIBRARY_DIR}"
LIBRARY DESTINATION "${QTK_PLUGIN_LIBRARY_DIR}"
RUNTIME DESTINATION "${QTK_PLUGIN_LIBRARY_DIR}"
@ -57,7 +57,7 @@ target_sources(
widgetplugincollection.cpp widgetplugincollection.h
widgetplugin.cpp widgetplugin.h
)
target_link_libraries(qtk_collection PUBLIC qtk-plugin-library)
target_link_libraries(qtk_collection PUBLIC qtk_plugin_library)
install(
TARGETS qtk_collection
@ -84,11 +84,11 @@ configure_file(
@ONLY
)
qt_add_executable(qtk-main ${QTK_APP_SOURCES})
target_link_libraries(qtk-main PRIVATE qtk-plugin-library)
qt_add_executable(qtk_main ${QTK_APP_SOURCES})
target_link_libraries(qtk_main PRIVATE qtk_plugin_library)
set_target_properties(
qtk-main PROPERTIES
qtk_main PROPERTIES
WIN32_EXECUTABLE TRUE
MACOSX_BUNDLE TRUE
MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION}
@ -96,14 +96,14 @@ set_target_properties(
)
install(
TARGETS qtk-main
TARGETS qtk_main
BUNDLE DESTINATION bin
RUNTIME DESTINATION bin
LIBRARY DESTINATION bin/lib
)
qt_generate_deploy_app_script(
TARGET qtk-main
TARGET qtk_main
FILENAME_VARIABLE QTK_DEPLOY_SCRIPT
NO_UNSUPPORTED_PLATFORM_ERROR
)
@ -121,16 +121,16 @@ if(WIN32)
if(TARGET Qt6::windeployqt)
add_custom_command(
TARGET qtk-main
TARGET qtk_main
POST_BUILD
COMMAND set PATH=%PATH%$<SEMICOLON>${qt6_install_prefix}
COMMAND Qt6::windeployqt --dir "${CMAKE_BINARY_DIR}/windeployqt" "$<TARGET_FILE_DIR:qtk-main>/$<TARGET_FILE_NAME:qtk-main>"
COMMAND Qt6::windeployqt --dir "${CMAKE_BINARY_DIR}/windeployqt" "$<TARGET_FILE_DIR:qtk_main>/$<TARGET_FILE_NAME:qtk_main>"
)
install(DIRECTORY "${CMAKE_BINARY_DIR}/windeployqt/" DESTINATION bin)
endif()
if(MSVC AND TARGET Qt6::qmake)
set(VSUSER_FILE "${CMAKE_CURRENT_BINARY_DIR}/qtk-main.vcxproj.user")
set(VSUSER_FILE "${CMAKE_CURRENT_BINARY_DIR}/qtk_main.vcxproj.user")
file(TO_NATIVE_PATH "${CMAKE_BINARY_DIR}/extern/assimp/assimp/bin" assimp_bin)
file(WRITE ${VSUSER_FILE} "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n")
file(APPEND ${VSUSER_FILE} "<Project xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\n")

View File

@ -44,46 +44,46 @@ set(
)
qt6_add_big_resources(QTK_LIBRARY_SOURCES "${QTK_RESOURCES}/resources.qrc")
qt_add_library(qtk-library STATIC)
target_sources(qtk-library PRIVATE ${QTK_LIBRARY_SOURCES})
qt_add_library(qtk_library STATIC)
target_sources(qtk_library PRIVATE ${QTK_LIBRARY_SOURCES})
target_sources(
qtk-library PUBLIC
qtk_library PUBLIC
FILE_SET HEADERS
BASE_DIRS "${CMAKE_SOURCE_DIR}/src"
FILES ${QTK_LIBRARY_PUBLIC_HEADERS}
)
if(QTK_DEBUG)
target_compile_definitions(qtk-library PUBLIC QTK_DEBUG)
target_compile_definitions(qtk_library PUBLIC QTK_DEBUG)
endif()
set_target_properties(
qtk-library PROPERTIES
qtk_library PROPERTIES
WIN32_EXECUTABLE TRUE
MACOSX_BUNDLE TRUE
VERSION ${PROJECT_VERSION}
)
target_link_libraries(
qtk-library PUBLIC
qtk_library PUBLIC
Qt6::Core Qt6::OpenGLWidgets Qt6::Widgets
)
if(QTK_UPDATE_SUBMODULES OR NOT ASSIMP_NEW_INTERFACE)
target_link_libraries(qtk-library PUBLIC assimp)
target_link_libraries(qtk_library PUBLIC assimp)
elseif(ASSIMP_NEW_INTERFACE)
target_link_libraries(qtk-library PUBLIC assimp::assimp)
target_link_libraries(qtk_library PUBLIC assimp::assimp)
endif()
if(WIN32)
target_link_libraries(qtk-library PUBLIC OpenGL::GL)
target_link_libraries(qtk_library PUBLIC OpenGL::GL)
endif()
# System install for qtk-library
# System install for qtk_library
install(
TARGETS qtk-library
# Associate qtk-library target with qtk-export
EXPORT qtk-export
TARGETS qtk_library
# Associate qtk_library target with qtk-export
EXPORT qtk_export
FILE_SET HEADERS DESTINATION include
BUNDLE DESTINATION lib
LIBRARY DESTINATION lib
@ -92,9 +92,9 @@ install(
INCLUDES DESTINATION include
)
## Install qtk-library to Qt Designer to support widget plugins.
## Install qtk_library to Qt Designer to support widget plugins.
install(
TARGETS qtk-library
TARGETS qtk_library
BUNDLE DESTINATION "${QTK_PLUGIN_LIBRARY_DIR}"
LIBRARY DESTINATION "${QTK_PLUGIN_LIBRARY_DIR}"
ARCHIVE DESTINATION "${QTK_PLUGIN_LIBRARY_DIR}"