versor icon indicating copy to clipboard operation
versor copied to clipboard

Add support for modern cmake targets.

Open CarloWood opened this issue 2 months ago • 0 comments

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).

CarloWood avatar Nov 05 '25 17:11 CarloWood