-
Notifications
You must be signed in to change notification settings - Fork 103
Convert Makefiles to cmake
#44
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
Changes from all commits
fdc56da
1462023
914109f
229c9e7
7345287
7fdd692
45af547
6986352
ae73d7e
60a2598
3d13f92
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 |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| language: cpp | ||
|
|
||
| matrix: | ||
| include: | ||
| - name: "Linux (gcc)" | ||
| os: linux | ||
| compiler: gcc | ||
| addons: | ||
| apt: | ||
| packages: valgrind | ||
| script: | ||
| - ctest --verbose --output-on-failure --script cmake/ctest-gcc.cmake | ||
| before_deploy: | ||
| - mkdir build | ||
| - cd build | ||
| - cmake -D CMAKE_BUILD_TYPE=Release .. | ||
| - cd .. | ||
| - cpack -G ZIP --config cmake/cpack-linux.cmake | ||
| deploy: | ||
| provider: releases | ||
| api_key: ${GITHUB_TOKEN} | ||
| file_glob: true | ||
| file: "*.zip" | ||
| skip_cleanup: true | ||
| on: | ||
| tags: true | ||
|
|
||
| - name: "Linux (clang)" | ||
| os: linux | ||
| compiler: clang | ||
| script: | ||
| - ctest --verbose --output-on-failure --script cmake/ctest-clang.cmake | ||
|
|
||
| - name: "OSX" | ||
| os: osx | ||
| script: | ||
| - ctest --verbose --output-on-failure --script cmake/ctest-osx.cmake | ||
|
|
||
| - name: "Windows" | ||
| os: windows | ||
| before_script: | ||
| - mkdir build | ||
| - cd build | ||
| - cmake .. | ||
| - cmake --build . | ||
| script: | ||
| - cmake --build . --target RUN_TESTS | ||
|
|
||
| allow_failures: | ||
| - os: windows | ||
| fast_finish: true | ||
|
|
||
| notifications: | ||
| email: false |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| cmake_minimum_required(VERSION 3.8.0) | ||
|
|
||
| project(pcg-super) | ||
|
|
||
| add_subdirectory(include) | ||
| add_subdirectory(sample) | ||
|
|
||
| enable_testing() | ||
| add_subdirectory(test-high) | ||
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| include("build/CPackConfig.cmake") | ||
|
|
||
| set(CPACK_INSTALL_CMAKE_PROJECTS | ||
| "build;pcg-super;ALL;/" | ||
| ) | ||
|
|
||
| set(CPACK_PACKAGE_FILE_NAME pcg-linux) | ||
| set(CPACK_PACKAGE_DESCRIPTION_SUMMARY | ||
| "PCG Random Number Generation, C++ Edition" | ||
| ) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| set(ENV{CC} "clang") | ||
| set(ENV{CXX} "clang++") | ||
|
|
||
| set(CTEST_PROJECT_NAME "pcg") | ||
| set(CTEST_SOURCE_DIRECTORY ".") | ||
| set(CTEST_BINARY_DIRECTORY "build-test-clang") | ||
| set(CTEST_CMAKE_GENERATOR "Unix Makefiles") | ||
|
|
||
| ctest_start("Continuous") | ||
| ctest_configure() | ||
| ctest_build() | ||
| ctest_test(RETURN_VALUE SUCCESS) | ||
|
|
||
| if(NOT ${SUCCESS} EQUAL 0) | ||
| message(SEND_ERROR "Testing failed.") | ||
| endif() |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| set(ENV{CC} "gcc") | ||
| set(ENV{CXX} "g++") | ||
| set(ENV{CXXFLAGS} "--coverage") | ||
|
|
||
| set(CTEST_PROJECT_NAME "pcg") | ||
| set(CTEST_SOURCE_DIRECTORY ".") | ||
| set(CTEST_BINARY_DIRECTORY "build-test-gcc") | ||
| set(CTEST_CMAKE_GENERATOR "Unix Makefiles") | ||
|
|
||
| set(CTEST_COVERAGE_COMMAND "/usr/bin/gcov") | ||
| set(CTEST_MEMORYCHECK_COMMAND "/usr/bin/valgrind") | ||
|
|
||
| ctest_start("Continuous") | ||
| ctest_configure() | ||
| ctest_build() | ||
| ctest_test(RETURN_VALUE SUCCESS) | ||
| ctest_coverage() | ||
| ctest_memcheck() | ||
|
|
||
| if(NOT ${SUCCESS} EQUAL 0) | ||
| message(SEND_ERROR "Testing failed.") | ||
| endif() |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| set(CTEST_PROJECT_NAME "pcg") | ||
| set(CTEST_SOURCE_DIRECTORY ".") | ||
| set(CTEST_BINARY_DIRECTORY "build-test-osx") | ||
| set(CTEST_CMAKE_GENERATOR "Unix Makefiles") | ||
|
|
||
| ctest_start("Continuous") | ||
| ctest_configure() | ||
| ctest_build() | ||
| ctest_test(RETURN_VALUE SUCCESS) | ||
|
|
||
| if(NOT ${SUCCESS} EQUAL 0) | ||
| message(SEND_ERROR "Testing failed.") | ||
| endif() |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| cmake_minimum_required(VERSION 3.8.0) | ||
|
|
||
| project(pcg VERSION 0.98.1 LANGUAGES CXX) | ||
|
Comment on lines
+1
to
+3
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. Only the root
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. Basically, Having more than 1 mkdir build
cd build
cmake ../include # or, cmake ../pcg, cmake ../src, whatever that folder would be
cmake --build . && cmake --build . --target installIf you want to also install sample files, do the super build: mkdir build
cd build
cmake ../
cmake --build && cmake --build . --target installAt the end of the day, you simplify the logic. 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. I guess I just find it weird since I've not seen any header only library separate them like that.
This should probably be raised as an issue and resolved before this PR is merged.
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. Agreed. |
||
|
|
||
| include(CMakePackageConfigHelpers) | ||
| include(GNUInstallDirs) | ||
|
|
||
| add_library(pcg INTERFACE) | ||
| add_library(pcg::pcg ALIAS pcg) | ||
|
|
||
| target_compile_features(pcg INTERFACE cxx_std_11) | ||
|
|
||
| target_include_directories(pcg | ||
| INTERFACE | ||
| $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}> | ||
| $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}> | ||
| ) | ||
|
|
||
| install(TARGETS pcg EXPORT pcg) | ||
|
|
||
| install(EXPORT pcg | ||
| FILE pcg-targets.cmake | ||
| NAMESPACE pcg:: | ||
| DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/pcg | ||
| ) | ||
|
|
||
| configure_package_config_file(pcg-config.cmake.in | ||
| ${CMAKE_CURRENT_BINARY_DIR}/pcg-config.cmake | ||
| INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/pcg | ||
| ) | ||
|
|
||
| write_basic_package_version_file(pcg-config-version.cmake | ||
| COMPATIBILITY SameMajorVersion | ||
| ) | ||
|
|
||
| install( | ||
| FILES | ||
| ${CMAKE_CURRENT_BINARY_DIR}/pcg-config.cmake | ||
| ${CMAKE_CURRENT_BINARY_DIR}/pcg-config-version.cmake | ||
| DESTINATION | ||
| ${CMAKE_INSTALL_LIBDIR}/cmake/pcg | ||
| ) | ||
|
|
||
| install( | ||
| DIRECTORY | ||
| ${CMAKE_CURRENT_SOURCE_DIR}/ | ||
| DESTINATION | ||
| ${CMAKE_INSTALL_INCLUDEDIR} | ||
| FILES_MATCHING PATTERN *.hpp | ||
| ) | ||
|
|
||
| include(CPack) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| @PACKAGE_INIT@ | ||
| # include(CMakeFindDependencyMacro) | ||
| # find_dependency(XXX) | ||
| include("${CMAKE_CURRENT_LIST_DIR}/pcg-targets.cmake") |
This file was deleted.
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.
These should be guarded like so
https://cliutils.gitlab.io/modern-cmake/chapters/testing.html
And building the samples should be an option, perhaps an option for installing them too.
Uh oh!
There was an error while loading. Please reload this page.
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.
I am not sure if you had time to read through the comments in the pull request thread. It's been almost a year since I made this pull request, and hence, I have forgot most of the code base. Yet, these concerns were discussed back then, and the summary could be found at least under this comment.
Have you tried, for instance
Basically, I had followed Daniel Pfeifer's talk, which is also listed in "Effective Modern CMake" link under https://cliutils.gitlab.io/modern-cmake/.
IMHO, the simplest solution with CMake is not to use options at all. This is also proposed/suggested by many different people. If you do not want to install/test anything, simply make an out-of-source build of
include. No need to remember any options, etc. If you want to include this project as a submodule, do so and point in your CMake to this include folder (e.g.,add_subdirectory(external/pcg-cpp/include)).