1
1
cmake_minimum_required (VERSION 3.7.2)
2
2
project (ghcfilesystem)
3
3
4
+ if (POLICY CMP0077)
5
+ cmake_policy (SET CMP0077 NEW)
6
+ endif ()
4
7
if (POLICY CMP0110)
5
- cmake_policy (PUSH)
6
- cmake_policy (SET CMP0110 OLD)
8
+ cmake_policy (SET CMP0110 NEW)
7
9
endif ()
8
10
9
- include (CMakeDependentOption)
10
-
11
- cmake_dependent_option(GHC_FILESYSTEM_BUILD_TESTING
12
- "Enable tests" ON
13
- "CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR" OFF )
14
- cmake_dependent_option(GHC_FILESYSTEM_BUILD_EXAMPLES
15
- "Build examples" ON
16
- "CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR" OFF )
17
- cmake_dependent_option(GHC_FILESYSTEM_WITH_INSTALL
18
- "With install target" ON
19
- "CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR" OFF )
11
+ if (CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR )
12
+ option (GHC_FILESYSTEM_BUILD_TESTING "Enable tests" ON )
13
+ option (GHC_FILESYSTEM_BUILD_EXAMPLES "Build examples" ON )
14
+ option (GHC_FILESYSTEM_WITH_INSTALL "With install target" ON )
15
+ else ()
16
+ option (GHC_FILESYSTEM_BUILD_EXAMPLES "Build examples" OFF )
17
+ option (GHC_FILESYSTEM_BUILD_TESTING "Enable tests" OFF )
18
+ option (GHC_FILESYSTEM_WITH_INSTALL "With install target" ON )
19
+ endif ()
20
20
21
21
if (NOT DEFINED CMAKE_CXX_STANDARD)
22
22
set (CMAKE_CXX_STANDARD 11)
@@ -34,8 +34,7 @@ target_include_directories(ghc_filesystem INTERFACE
34
34
target_compile_options (ghc_filesystem INTERFACE "$<$<C_COMPILER_ID:MSVC>:/utf-8>" )
35
35
target_compile_options (ghc_filesystem INTERFACE "$<$<CXX_COMPILER_ID:MSVC>:/utf-8>" )
36
36
37
- get_directory_property (hasParent PARENT_DIRECTORY )
38
- if (NOT hasParent)
37
+ if (GHC_FILESYSTEM_BUILD_TESTING OR GHC_FILESYSTEM_BUILD_EXAMPLES)
39
38
set (CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE )
40
39
set (CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR} /cmake/" )
41
40
include (GhcHelper)
@@ -53,12 +52,7 @@ endif()
53
52
if (GHC_FILESYSTEM_WITH_INSTALL)
54
53
include (CMakePackageConfigHelpers)
55
54
include (GNUInstallDirs)
56
-
57
55
install (DIRECTORY include / DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} )
58
56
install (TARGETS ghc_filesystem EXPORT ghcFilesystemConfig)
59
57
install (EXPORT ghcFilesystemConfig NAMESPACE ghcFilesystem:: DESTINATION ${CMAKE_INSTALL_LIBDIR} /cmake/ghcFilesystem)
60
58
endif ()
61
-
62
- if (POLICY CMP0110)
63
- cmake_policy (POP)
64
- endif ()
0 commit comments