Add support for modern cmake targets.#36
Open
CarloWood wants to merge 1 commit intowolftype:develfrom
Open
Conversation
Install (to CMAKE_INSTALL_PREFIX): `lib/cmake/Versor/VersorConfig.cmake`, `lib/cmake/Versor/VersorConfigVersion.cmake`, `lib/cmake/Versor/VersorTargets.cmake` and `lib/cmake/Versor/VersorTargets-release.cmake`. This allows third party projects to use `find_package(versor 0.2.0...<1.0 REQUIRED CONFIG)` or something similar. The cmake targets that one can then link against are `versor::vsr` and `versor::vsr_shared` (that also works if versor is used with an add_subdirectory). The version was randomly set to 0.2.0 (can be matched against in a find_package, see above). Removed incorrect double quotes around many variables that must be lists, not space separated strings of tokens. Also install the shared library (target `versor::vsr_shared`) as `lib/libvsr_shared.so` (the name doesn't really matter since users will only use the target name anyway). Both targets define VSR_PRECISION_DOUBLE or VSR_PRECISION_FLOAT. Note on `set(OpenGL_GL_PREFERENCE "GLVND")`: this was added to suppress a cmake warning. It tells cmake that if it can find both a LEGACY openGL install and a libglvnd, to just use the non-legacy libglvnd because the project will compile fine with it. Removed unused option BUILD_SCRATCH. Note that BUILD_DIRECTORY is no longer passed, nor used: That value is already available as CMAKE_BINARY_DIR, which in turn is used to set _OUT_LIB and _OUT_BIN, which are being used everywhere now (previously called LIBRARY_OUTPUT_PATH and EXECUTABLE_OUTPUT_PATH respectively). Instead of using `link_directories`, `include_directories`, `compile_definitions`, `compile_options` and `link_libraries`, that pollute every target project wide (especially bad if versor is used with `add_subdirectory`) each setting is added to one our targets specifically (using the target_* variants). This might influence existing projects that use versor with an `add_subdirectory` and then rely on globally available link- and include directories. But well - that is progress: they should, in that case, just add `versor::vsr` to their target_link_libraries (like everyone else from now on). Typical usage in a third party project is now: find_package(versor REQUIRED) add_executable(hello_nga hello_nga.cxx) target_link_libraries(hello_nga versor::vsr) There is no need anymore to use the VSR_LIBRARIES, VSR_INCLUDE_DIR VSR_LINK_DIR and/or VSR_FLAGS properties. Although I went out of my way to leave them in as-is; I think you should just remove the whole legacy block (or disable it by default).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Install (to CMAKE_INSTALL_PREFIX):
lib/cmake/Versor/VersorConfig.cmake,lib/cmake/Versor/VersorConfigVersion.cmake,lib/cmake/Versor/VersorTargets.cmakeandlib/cmake/Versor/VersorTargets-release.cmake.This allows third party projects to use
find_package(versor 0.2.0...<1.0 REQUIRED CONFIG)or something similar.
The cmake targets that one can then link against are
versor::vsrandversor::vsr_shared(that also works if versor is used with an add_subdirectory).
The version was randomly set to 0.2.0 (can be matched against in a find_package, see above).
Removed incorrect double quotes around many variables that must be lists, not space separated strings of tokens.
Also install the shared library (target
versor::vsr_shared) aslib/libvsr_shared.so(the name doesn't really matter since users will only use the target name anyway).Both targets define VSR_PRECISION_DOUBLE or VSR_PRECISION_FLOAT.
Note on
set(OpenGL_GL_PREFERENCE "GLVND"): this was added to suppress a cmake warning. It tells cmake that if it can find both a LEGACY openGL install and a libglvnd, to just use the non-legacy libglvnd because the project will compile fine with it.Removed unused option BUILD_SCRATCH.
Note that BUILD_DIRECTORY is no longer passed, nor used: That value is already available as CMAKE_BINARY_DIR, which in turn is used to set _OUT_LIB and _OUT_BIN, which are being used everywhere now (previously called LIBRARY_OUTPUT_PATH and EXECUTABLE_OUTPUT_PATH respectively).
Instead of using
link_directories,include_directories,compile_definitions,compile_optionsandlink_libraries, that pollute every target project wide (especially bad if versor is used withadd_subdirectory) each setting is added to one our targets specifically (using the target_* variants).This might influence existing projects that use versor with an
add_subdirectoryand then rely on globally available link- and include directories. But well - that is progress: they should, in that case, just addversor::vsrto their target_link_libraries (like everyone else from now on).Typical usage in a third party project is now:
find_package(versor REQUIRED)
add_executable(hello_nga hello_nga.cxx)
target_link_libraries(hello_nga versor::vsr)
There is no need anymore to use the VSR_LIBRARIES, VSR_INCLUDE_DIR VSR_LINK_DIR and/or VSR_FLAGS properties. Although I went out of my way to leave them in as-is; I think you should just remove the whole legacy block (or disable it by default).