bombomby / optick

C++ Profiler For Games
https://optick.dev
MIT License
2.95k stars 296 forks source link

Add cmake install so that Optick can be found through FindPackage #103

Closed Lectem closed 4 years ago

Lectem commented 4 years ago

Those changes add installation to the CMakeLists.txt. This way a user can build the install target and on the consumer side do for example:

find_package(Optick CONFIG REQUIRED)
add_executable(test main.cpp)
target_link_libraries(test PRIVATE Optick::OptickCore)

Note that I had to add the version to the project command which will need to be kept up to date, and SameMajorVersion in write_basic_package_version_file assuming semantic versioning. If it is not the case, you can check https://cmake.org/cmake/help/latest/module/CMakePackageConfigHelpers.html#command:write_basic_package_version_file for the list of possible version compatibility modes.

Also, this should work on old versions of CMake, but I am not sure if all the other commands already used in the rest of the file are available in 3.2. It might be better to update the CMake required version (I'd suggest a minimum of 3.8, ideally 3.14). I tested this on CMake 3.14+ only.

malytomas commented 4 years ago

Please make the installation optional, so that it is not installed alongside projects that use add_subdirectory to integrate Optick.

Lectem commented 4 years ago

It seems the appveyor build failure is unrelated (some warning treated as error), would it be possible to retrigger the build against latest master ?