-
Notifications
You must be signed in to change notification settings - Fork 7
added initial cmakelists.txt file. #17
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: master
Are you sure you want to change the base?
Changes from all commits
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,68 @@ | ||
| cmake_minimum_required(VERSION 3.8) | ||
| cmake_policy(VERSION 3.8) | ||
|
|
||
| ############################################### | ||
| # NOTE FOR THOSE UNFORTUNATES WHO DON'T KNOW OF HUNTER | ||
|
Collaborator
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. This seems like a lot of overkill for just getting Boost. Not to mention that "those unfortunates" is a rather condescending tone to take. I get the impression from this text that you just like hunter a lot and as a result it's become your hammer for which every problem needs to be a nail. Could you explain why |
||
| # | ||
| # Hunter is a dependency manager for CMake. It automatically downloads, configures and compiles | ||
| # libraries that your program depends on. | ||
| # Hunter is clever enough to understand the toolchain file you have specified on the command line, and | ||
| # build dependencies (including quite demanding ones like boost, openssl etc) with the correct command line arguments. | ||
| # Tt then caches the build by target, toolchain and configuration so that you never have to build that | ||
| # configuration again. | ||
| # see https://github.com/ruslo/hunter | ||
| # | ||
| # If you don't want to use Hunter then simply define the variable HUNTER_ENABLED=OFF or USE_HUNTER_FOR_DEPENDENCIES=OFF | ||
| # on the CMAKE command line | ||
| if (DEFINED HUNTER_ENABLED) | ||
| option(USE_HUNTER_FOR_DEPENDENCIES "Use the hunter package manager to find boost" ${HUNTER_ENABLED}) | ||
| else () | ||
| option(USE_HUNTER_FOR_DEPENDENCIES "Use the hunter package manager to find boost" ON) | ||
| endif () | ||
|
|
||
| option(IMPL_PTR_BUILD_TESTS "build the tests" ON) | ||
|
|
||
| if (USE_HUNTER_FOR_DEPENDENCIES) | ||
| include(cmake/HunterGate.cmake) | ||
| HunterGate( | ||
| URL "https://github.com/ruslo/hunter/archive/v0.19.96.tar.gz" | ||
| SHA1 "8316d0491ee03a918d2e0973aaf5878d9bcfe472" | ||
| ) | ||
| endif () | ||
| # | ||
| # at this point, HUNTER_ENABLED is guaranteed to be set to ON or OFF | ||
| # | ||
|
|
||
| project(ImplPtr) | ||
| set(CMAKE_CXX_STANDARD 14) | ||
|
Collaborator
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.
|
||
|
|
||
| if (HUNTER_ENABLED) | ||
| hunter_add_package(Sugar) | ||
| include(${SUGAR_ROOT}/cmake/Sugar) | ||
| include(sugar_files) | ||
| include(sugar_include) | ||
| hunter_add_package(Boost) | ||
| find_package(Boost CONFIG REQUIRED) | ||
| else () | ||
| find_package(Boost REQUIRED) | ||
| endif () | ||
|
|
||
|
|
||
| add_library(impl_ptr INTERFACE) | ||
| target_include_directories(impl_ptr SYSTEM INTERFACE | ||
| $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include> | ||
|
Collaborator
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. There are no generated sources, so adding the binary dir is not necessary. |
||
| $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>) | ||
|
Collaborator
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. You're adding a
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. I Haven't got round to the that bit yet. The first commit was simply to get this building and running tests on any platform without having to install any dependencies. |
||
| target_link_libraries(impl_ptr INTERFACE Boost::boost) | ||
|
|
||
|
|
||
| if (IMPL_PTR_BUILD_TESTS) | ||
| if (HUNTER_ENABLED) | ||
| sugar_include(test) | ||
| else () | ||
| find_package(Boost REQUIRED) | ||
|
Collaborator
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. Why do you repeat the package detection that you've already done above?
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. That's a harmless oversight. Repeating a dependency in cmake has no ill effects.
Collaborator
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. No, but it is a reason to not merge this PR in. "It works" isn't good enough, it needs to be understandable too. |
||
| add_subdirectory(test) | ||
| endif () | ||
|
|
||
| add_executable(impl_ptr_tests ${TEST_SOURCES}) | ||
|
Collaborator
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. Erm? Why aren't you creating this target directly in the
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. That's one way. Easy to do if that's where you want it. |
||
| target_link_libraries(impl_ptr_tests PRIVATE impl_ptr) | ||
| 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.
This is not necessary, the
cmake_minimum_requiredalready defaults to the same policy version.