Skip to content

Commit

Permalink
Merge pull request #30 from asmaloney/options-submodule
Browse files Browse the repository at this point in the history
CMake: Do not include test and example options if including as submodule
  • Loading branch information
gulrak authored Sep 27, 2019
2 parents 9a3c37f + ccdd8ec commit 49df1ea
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
cmake_minimum_required(VERSION 3.7.2)
project(ghcfilesystem)

option(BUILD_TESTING "Enable tests" ON)
option(BUILD_EXAMPLES "Build examples" ON)
include(CMakeDependentOption)

cmake_dependent_option(GHC_FILESYSTEM_BUILD_TESTING
"Enable tests" ON
"CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR" OFF)
cmake_dependent_option(GHC_FILESYSTEM_BUILD_EXAMPLES
"Build examples" ON
"CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR" OFF)

if(NOT DEFINED CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 11)
Expand Down Expand Up @@ -32,12 +38,12 @@ if(NOT hasParent)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake/")
include(GhcHelper)

if(BUILD_TESTING)
if(GHC_FILESYSTEM_BUILD_TESTING)
enable_testing()
add_subdirectory(test)
endif()

if(BUILD_EXAMPLES)
if(GHC_FILESYSTEM_BUILD_EXAMPLES)
add_subdirectory(examples)
endif()
endif()
Expand Down

0 comments on commit 49df1ea

Please sign in to comment.