开发者

CMake User-specified Options

开发者 https://www.devze.com 2023-03-07 10:03 出处:网络
I want to make CMake configuration for a project that depends on OGRE. Obviously, the user needs to specify the directory where OGRE is installed. Is it possible to specify such an option in CMake? I

I want to make CMake configuration for a project that depends on OGRE. Obviously, the user needs to specify the directory where OGRE is installed. Is it possible to specify such an option in CMake? I want to be able to write something like:

include_directories(${OGRE_HOME})

Where the variable OGRE_HOME is to be specified by the user.

Still better, is it possible to make CMake automatically looks for OGRE, or any other librar开发者_运维技巧y?!

Thanks!


Your best bet is to search for a FindOgre.cmake, which can do this for you. Ogre already provides one in $Ogre_DIR\CMake.

You can copy this one to your project (or use CMAKE_MODULE_PATH to specify an additional location with findXXX.cmake files). You can then use find_package( Ogre ) in your cmakelists.txt to search for Ogre and your user needs to specify an environment variable OGRE_HOME or a Cmake-variable OGRE_HOME.

In general: If you rely on 3rd-party libraries, you should have findXXX.cmake files, which can be called by CMake's find_package command. For many common 3rdparty libs, these files are already provided by cmake.

0

精彩评论

暂无评论...
验证码 换一张
取 消