In the top level of your directory tree for your project, add a cmake
folder with a Modules
subfolder:
your_project_dir/
|-src/
|-cmake/
| |-Modules/
|-CMakeLists.txt
Put the QxtConfig.cmake
file in cmake/Modules/
. In your CMakeLists.txt
, add the following lines:
SET(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/Modules/")
INCLUDE(${CMAKE_MODULE_PATH}/QxtConfig.cmake)
This will run the code in the QxtConfig.cmake
file.
Note that if the file were called FindQxt.cmake
, you could call FIND_PACKAGE(Qtx)
instead of INCLUDE(${CMAKE_MODULE_PATH}/QxtConfig.cmake)
.
Note
Of course, you don't need to do the whole cmake/Modules/
thing. You could just put the QxtConfig.cmake
file next to CMakeLists.txt
and omit everything about CMAKE_MODULE_PATH
, but it's good practice to have a Modules
directory because the number of extra module files can grow in a big project.