Reputation: 63
I am in the process of writing my project's CMakeLists.txt file. My project relies on an external dependency, GLFW, luckily for me GLFW also uses CMake for its build system. I am using find_package() and git submodules to handle dependency management, currently this is how my CMakeLists.txt file looks like:
# CMake version
cmake_minimum_required(VERSION 3.0)
# project name
project(CHIP-8)
# dependency management
find_package(OpenGL REQUIRED)
find_package(glfw)
if(NOT glfw)
message("Unable to locate glfw.")
message("Cloning the repository.")
execute_process(
COMMAND
git submodule update --init -- libs
WORKING_DIRECTORY
${CMAKE_CURRENT_SOURCE_DIR}
)
message("Building glfw.")
add_subdirectory(libs/glfw)
endif()
From my limited understanding of CMake the command add_subdirectory(libs/glfw)
runs CMake on the recently cloned glfw sub-module. The problem is a lot of unnecessary features are part of the default build for GLFW such as examples, unit tests, and documentation.
The documentation for compiling GLFW lists the CMake options for disabling these features GLFW_BUILD_EXAMPLES
, GLFW_BUILD_TESTS
, and GLFW_BUILD_DOCS
.
I have two questions, the first being how can I specify these options, and the second is the argument I pass for find_package accurate (I do have GLFW installed on my system yet every time I build it still attempts to clone and build the repository).
Upvotes: 1
Views: 1120
Reputation: 63
Found my answer in a similar question. All I had to do was add:
option(GLFW_BUILD_EXAMPLES OFF)
option(GLFW_BUILD_TESTS OFF)
option(GLFW_BUILD_DOCS OFF)
right before add_subdirectory(libs/glfw)
.
Upvotes: 2