-
Notifications
You must be signed in to change notification settings - Fork 1
Update and cleanup cmake files #5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from 1 commit
9cd5fad
a3356aa
fdde14c
a2597e3
6cbe688
28460a7
b1e0ed4
4a7c409
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,77 +1,123 @@ | ||
| format: | ||
| tab_size: 2 | ||
| line_width: 100 | ||
| dangle_parens: true | ||
|
|
||
| markup: | ||
| enable_markup: false | ||
|
|
||
| parse: | ||
| additional_commands: | ||
| cpmaddpackage: | ||
| pargs: | ||
| nargs: '*' | ||
| flags: [] | ||
| spelling: CPMAddPackage | ||
| kwargs: &cpmaddpackagekwargs | ||
| NAME: 1 | ||
| FORCE: 1 | ||
| VERSION: 1 | ||
| GIT_TAG: 1 | ||
| kwargs: | ||
| DOWNLOAD_COMMAND: 1 | ||
| DOWNLOAD_NAME: 1 | ||
| DOWNLOAD_NO_EXTRACT: 1 | ||
| DOWNLOAD_ONLY: 1 | ||
| FIND_PACKAGE_ARGUMENTS: 1 | ||
| FORCE: 1 | ||
| GITHUB_REPOSITORY: 1 | ||
| GITLAB_REPOSITORY: 1 | ||
| GIT_REPOSITORY: 1 | ||
| GIT_SHALLOW: 1 | ||
| GIT_TAG: 1 | ||
| HTTP_PASSWORD: 1 | ||
| HTTP_USERNAME: 1 | ||
| NAME: 1 | ||
| NO_CACHE: 1 | ||
| OPTIONS: + | ||
| SOURCE_DIR: 1 | ||
| SVN_REPOSITORY: 1 | ||
| SVN_REVISION: 1 | ||
| SOURCE_DIR: 1 | ||
| URL: 1 | ||
| URL_HASH: 1 | ||
| URL_MD5: 1 | ||
| VERSION: 1 | ||
| pargs: | ||
| flags: [] | ||
| nargs: '*' | ||
| spelling: CPMAddPackage | ||
| cpmdeclarepackage: | ||
| kwargs: | ||
| DOWNLOAD_COMMAND: 1 | ||
| DOWNLOAD_NAME: 1 | ||
| DOWNLOAD_NO_EXTRACT: 1 | ||
| DOWNLOAD_ONLY: 1 | ||
| FIND_PACKAGE_ARGUMENTS: 1 | ||
| NO_CACHE: 1 | ||
| FORCE: 1 | ||
| GITHUB_REPOSITORY: 1 | ||
| GITLAB_REPOSITORY: 1 | ||
| GIT_REPOSITORY: 1 | ||
| GIT_SHALLOW: 1 | ||
| GIT_TAG: 1 | ||
| HTTP_PASSWORD: 1 | ||
| HTTP_USERNAME: 1 | ||
| NAME: 1 | ||
| NO_CACHE: 1 | ||
| OPTIONS: + | ||
| SOURCE_DIR: 1 | ||
| SVN_REPOSITORY: 1 | ||
| SVN_REVISION: 1 | ||
| URL: 1 | ||
| URL_HASH: 1 | ||
| URL_MD5: 1 | ||
| VERSION: 1 | ||
| pargs: | ||
| flags: [] | ||
| nargs: '*' | ||
| spelling: CPMDeclarePackage | ||
| cpmfindpackage: | ||
| kwargs: | ||
| DOWNLOAD_COMMAND: 1 | ||
| DOWNLOAD_NAME: 1 | ||
| DOWNLOAD_NO_EXTRACT: 1 | ||
| HTTP_USERNAME: 1 | ||
| DOWNLOAD_ONLY: 1 | ||
| FIND_PACKAGE_ARGUMENTS: 1 | ||
| FORCE: 1 | ||
| GITHUB_REPOSITORY: 1 | ||
| GITLAB_REPOSITORY: 1 | ||
| GIT_REPOSITORY: 1 | ||
| GIT_SHALLOW: 1 | ||
| GIT_TAG: 1 | ||
| HTTP_PASSWORD: 1 | ||
| HTTP_USERNAME: 1 | ||
| NAME: 1 | ||
| NO_CACHE: 1 | ||
| OPTIONS: + | ||
| cpmfindpackage: | ||
| SOURCE_DIR: 1 | ||
| SVN_REPOSITORY: 1 | ||
| SVN_REVISION: 1 | ||
| URL: 1 | ||
| URL_HASH: 1 | ||
| URL_MD5: 1 | ||
| VERSION: 1 | ||
| pargs: | ||
| nargs: '*' | ||
| flags: [] | ||
| spelling: CPMFindPackage | ||
| kwargs: *cpmaddpackagekwargs | ||
| cpmdeclarepackage: | ||
| pargs: | ||
| nargs: '*' | ||
| flags: [] | ||
| spelling: CPMDeclarePackage | ||
| kwargs: *cpmaddpackagekwargs | ||
| spelling: CPMFindPackage | ||
| cpmgetpackageversion: | ||
| pargs: 2 | ||
| spelling: CPMGetPackageVersion | ||
| cpmregisterpackage: | ||
| pargs: 1 | ||
| spelling: CPMRegisterPackage | ||
| cpmusepackagelock: | ||
| pargs: 1 | ||
| spelling: CPMUsePackageLock | ||
| packageproject: | ||
| pargs: | ||
| nargs: '*' | ||
| flags: [] | ||
| spelling: packageProject | ||
| kwargs: | ||
| NAME: 1 | ||
| VERSION: 1 | ||
| NAMESPACE: 1 | ||
| INCLUDE_DIR: 1 | ||
| INCLUDE_DESTINATION: 1 | ||
| BINARY_DIR: 1 | ||
| COMPATIBILITY: 1 | ||
| VERSION_HEADER: 1 | ||
| EXPORT_HEADER: 1 | ||
| DISABLE_VERSION_SUFFIX: 1 | ||
| DEPENDENCIES: + | ||
| cpmusepackagelock: | ||
| pargs: 1 | ||
| spelling: CPMUsePackageLock | ||
| cpmregisterpackage: | ||
| pargs: 1 | ||
| spelling: CPMRegisterPackage | ||
| cpmgetpackageversion: | ||
| pargs: 2 | ||
| spelling: CPMGetPackageVersion | ||
| DISABLE_VERSION_SUFFIX: 1 | ||
| DISABLE_CHECK_REQUIRED_COMPONENTS: 1 | ||
| EXPORT_HEADER: 1 | ||
| INCLUDE_DESTINATION: 1 | ||
| INCLUDE_DIR: 1 | ||
| NAME: 1 | ||
| NAMESPACE: 1 | ||
| VERSION: 1 | ||
| VERSION_HEADER: 1 | ||
| pargs: | ||
| flags: [] | ||
| nargs: '*' | ||
| spelling: packageProject | ||
| format: | ||
| line_width: 100 | ||
| tab_size: 2 | ||
| dangle_parens: true | ||
|
|
||
| markup: | ||
| enable_markup: false |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,11 +1,11 @@ | ||
| cmake_minimum_required(VERSION 3.14...3.20) | ||
| cmake_minimum_required(VERSION 3.21...3.25) | ||
|
|
||
| # ---- Project ---- | ||
|
|
||
| # Note: update this to your new project's name and version | ||
| project( | ||
| MathFunctions | ||
| VERSION 1.0.0 | ||
| VERSION 1.0.1 | ||
| LANGUAGES CXX | ||
| ) | ||
|
|
||
|
|
@@ -14,8 +14,7 @@ project( | |
| if(PROJECT_SOURCE_DIR STREQUAL PROJECT_BINARY_DIR) | ||
| message( | ||
| FATAL_ERROR | ||
| "In-source builds not allowed. Please make a new directory (called a build directory) \ | ||
| and run CMake from there." | ||
| "In-source builds not allowed. Please make a new directory (called a build directory) and run CMake from there." | ||
| ) | ||
| endif() | ||
|
|
||
|
|
@@ -29,22 +28,17 @@ include(cmake/options.cmake) | |
| include(cmake/CPM.cmake) | ||
|
|
||
| # PackageProject.cmake will be used to make our target installable | ||
| CPMAddPackage( | ||
| NAME PackageProject.cmake | ||
| GITHUB_REPOSITORY ClausKlein/PackageProject.cmake | ||
| # VERSION CK1.6.0 | ||
| GIT_TAG 4ac95860ba72bb0eb324c4d63e35fb59be3bd50d | ||
| ) | ||
| CPMAddPackage("gh:TheLartians/PackageProject.cmake@1.10.0") | ||
|
|
||
| set(COMPONENT_TARGETS_ENABLED NO) # Note: DO not set! CK | ||
| # NO! set(COMPONENT_TARGETS_ENABLED NO) # Note: DO not set! CK | ||
| set(PROJECT_NAMESPACE ${PROJECT_NAME}) | ||
| set(PROJECT_VERSION_INCLUDE_DIR ${PROJECT_BINARY_DIR}/PackageProjectInclude) | ||
| include_directories(${PROJECT_VERSION_INCLUDE_DIR}) | ||
|
|
||
| set(NAMESPACE_HEADER_LOCATION ${CMAKE_CURRENT_LIST_DIR}/include) | ||
| set(INCLUDE_INSTALL_DIR include/${PROJECT_NAMESPACE}-${PROJECT_VERSION}) # XXX VERSION_SUFFIX | ||
| string(TOLOWER ${PROJECT_NAMESPACE} PROJECT_HEADER_LOCATION) | ||
| # TODO: needed to be lower case? CK | ||
| # TODO: why needed to be lower case? CK | ||
|
|
||
| # ---- Add components libraries here ---- | ||
|
|
||
|
|
@@ -74,7 +68,7 @@ set_target_properties( | |
| # header paths | ||
| string(TOLOWER ${PROJECT_NAMESPACE}/version.h PROJECT_VERSION_HEADER) | ||
| string(TOLOWER ${PROJECT_NAMESPACE}/${PROJECT_NAMESPACE}_export.h PROJECT_EXPORT_HEADER) | ||
| # TODO: needed to be lower case? CK | ||
| # TODO: why needed to be lower case? CK | ||
|
|
||
| # Note: This needs to be done after all install(TARGETS ...) commands! | ||
| # generate and install export targets file | ||
|
|
@@ -95,14 +89,18 @@ packageProject( | |
| INCLUDE_DESTINATION ${INCLUDE_INSTALL_DIR} | ||
| VERSION_HEADER ${PROJECT_VERSION_HEADER} | ||
| EXPORT_HEADER ${PROJECT_EXPORT_HEADER} | ||
| COMPATIBILITY SameMajorVersion # XXX DISABLE_VERSION_SUFFIX NOT YET! CK | ||
| DISABLE_CHECK_REQUIRED_COMPONENTS YES | ||
| COMPATIBILITY SameMajorVersion | ||
| # XXX DISABLE_VERSION_SUFFIX NOT YET! CK | ||
| DISABLE_CHECK_REQUIRED_COMPONENTS YES | ||
|
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. needed too! |
||
| ) | ||
|
|
||
| # generate the export targets for the build tree. Note: The file created by this command is specific | ||
| # to the build tree and should never be installed! | ||
| export( | ||
| EXPORT ${PROJECT_NAMESPACE}Targets | ||
| FILE ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAMESPACE}Targets.cmake | ||
| NAMESPACE ${PROJECT_NAMESPACE}:: | ||
| ) | ||
| # generate the export targets for the build tree. | ||
| # if(COMPONENT_TARGETS_ENABLED) | ||
| # # Note: The file created by this command is specific to the build tree | ||
| # # and and must be created after packageProject()! CK | ||
| # export( | ||
| # EXPORT ${PROJECT_NAMESPACE}Targets | ||
| # FILE ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAMESPACE}Targets.cmake | ||
| # NAMESPACE ${PROJECT_NAMESPACE}:: | ||
| # ) | ||
| # endif() | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| if(CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND CMAKE_CXX_SIMULATE_ID MATCHES "MSVC") | ||
| target_compile_options(${PROJECT_NAME} PRIVATE /W4 /WX) | ||
| elseif(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang") | ||
| target_compile_options(${PROJECT_NAME} PRIVATE -Wall -Wextra -Wpedantic -Werror -Wshadow) | ||
|
|
||
| if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND CMAKE_CXX_COMPILER_VERSION GREATER_EQUAL 10.0) | ||
| target_compile_options(${PROJECT_NAME} PRIVATE -Wdeprecated-copy-dtor -Wnewline-eof) | ||
| endif() | ||
| elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") | ||
| string(REGEX REPLACE " /W[0-4]" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") | ||
| target_compile_options(${PROJECT_NAME} PRIVATE /W4 /WX) | ||
| endif() |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,7 +5,7 @@ add_library( | |
| Addition Addition.cxx ${NAMESPACE_HEADER_LOCATION}/${PROJECT_HEADER_LOCATION}/Addition.h | ||
| ) | ||
|
|
||
| add_library(${PROJECT_NAMESPACE}::Addition ALIAS Addition) | ||
| add_library(${PROJECT_NAMESPACE}::Addition ALIAS Addition) # NOTE: needed! CK | ||
|
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. needed |
||
|
|
||
| # Note: for SameMajorVersion upgrade stategie | ||
| set_target_properties( | ||
|
|
@@ -24,7 +24,7 @@ target_include_directories( | |
| $<INSTALL_INTERFACE:${INCLUDE_INSTALL_DIR}> | ||
| ) | ||
|
|
||
| # install the target and create export-set | ||
| # NOTE: Need to install the target and create export-set manually! CK | ||
|
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. needed |
||
| install( | ||
| TARGETS Addition | ||
| EXPORT ${PROJECT_NAMESPACE}Targets | ||
|
|
@@ -41,12 +41,12 @@ install( | |
| # DESTINATION ${INCLUDE_INSTALL_DIR}/${PROJECT_NAMESPACE} | ||
| # ) | ||
|
|
||
| if(COMPONENT_TARGETS_ENABLED) | ||
| # generate and install export file | ||
| install( | ||
| EXPORT ${PROJECT_NAMESPACE}Targets | ||
| FILE ${PROJECT_NAMESPACE}AdditionTargets.cmake | ||
| NAMESPACE ${PROJECT_NAMESPACE}:: | ||
| DESTINATION lib/cmake/${PROJECT_NAMESPACE} | ||
| ) | ||
| endif() | ||
| # if(COMPONENT_TARGETS_ENABLED) | ||
| # # NOTE: generate and install export file for this target! CK | ||
| # install( | ||
| # EXPORT ${PROJECT_NAMESPACE}Targets | ||
| # FILE ${PROJECT_NAMESPACE}AdditionTargets.cmake | ||
| # NAMESPACE ${PROJECT_NAMESPACE}:: | ||
| # DESTINATION lib/cmake/${PROJECT_NAMESPACE} | ||
| # ) | ||
| # endif() | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
needed