-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
107 lines (90 loc) · 3.23 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
if (WIN32)
# Needs 3.15 for CMAKE_MSVC_RUNTIME_LIBRARY.
cmake_minimum_required(VERSION 3.15)
else()
cmake_minimum_required(VERSION 3.10)
endif()
if (POLICY CMP0144)
cmake_policy(SET CMP0144 NEW)
endif()
project(VFC)
# Build options
# Use if since BUILD_SHARED_LIBS defaults to unset.
if (BUILD_SHARED_LIBS)
set(VFC_SHARED_DEFAULT ON)
else()
set(VFC_SHARED_DEFAULT OFF)
endif()
set(VFC_SHARED ${VFC_SHARED_DEFAULT} CACHE BOOL "Build VFC using shared libraries.")
set(VFC_STATIC_RUNTIME OFF CACHE BOOL "Use static runtime library on Windows.")
# Options for disabling portions of the build.
set(VFC_BUILD_TESTS ON CACHE BOOL "Build unit tests.")
set(VFC_BUILD_DOCS ON CACHE BOOL "Build documentation.")
set(VFC_BUILD_TOOL ON CACHE BOOL "Build the tool.")
# Misc options.
set(VFC_OUTPUT_DIR ${CMAKE_BINARY_DIR}/output CACHE PATH
"Folder for placing the build output.")
set(VFC_EXPORTS_DIR ${CMAKE_BINARY_DIR}/cmake CACHE PATH
"Folder for placing the cmake exports while building. Useful when embedding in other projects.")
set(VFC_ROOT_FOLDER VFC CACHE STRING
"Root folder for the VFC projects. Usefull when embedding in other projects.")
set(VFC_INSTALL ON CACHE BOOL "Allow installation for VFC components.")
set(VFC_INSTALL_SET_RPATH ON CACHE BOOL "Set rpath for library and tool on installation.")
if (APPLE AND NOT IOS AND NOT CMAKE_OSX_DEPLOYMENT_TARGET)
set(CMAKE_OSX_DEPLOYMENT_TARGET 10.11 CACHE STRING "Minimum macOS deployment version." FORCE)
endif()
if (VFC_BUILD_TESTS)
find_package(GTest QUIET)
if (NOT GTEST_FOUND)
message("GTest not installed. Skipping tests.")
endif()
endif()
if (VFC_BUILD_DOCS)
find_package(Doxygen QUIET)
if (NOT DOXYGEN_FOUND)
message("Doxygon not installed. Skipping documentation.")
endif()
endif()
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
if (VFC_SHARED)
set(VFC_LIB SHARED)
else()
set(VFC_LIB STATIC)
endif()
if (VFC_OUTPUT_DIR)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${VFC_OUTPUT_DIR})
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${VFC_OUTPUT_DIR})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${VFC_OUTPUT_DIR})
endif()
set(VFC_MAJOR_VERSION 2)
set(VFC_MINOR_VERSION 1)
set(VFC_PATCH_VERSION 5)
set(VFC_VERSION ${VFC_MAJOR_VERSION}.${VFC_MINOR_VERSION}.${VFC_PATCH_VERSION})
set(VFC_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
include(cmake/config.cmake)
include(cmake/install.cmake)
add_subdirectory(lib)
if (VFC_BUILD_TOOL)
add_subdirectory(tool)
endif()
if (VFC_INSTALL)
include(CMakePackageConfigHelpers)
set(versionPath ${VFC_EXPORTS_DIR}/VFCConfigVersion.cmake)
write_basic_package_version_file(${versionPath}
VERSION ${VFC_VERSION}
COMPATIBILITY SameMajorVersion)
set(configPath ${VFC_EXPORTS_DIR}/VFCConfig.cmake)
set(configLines
"include(\${CMAKE_CURRENT_LIST_DIR}/vfc_lib-targets.cmake)\n"
"set(VFC_LIBRARIES VFC::lib)\n"
"get_target_property(VFC_INCLUDE_DIRS VFC::lib INTERFACE_INCLUDE_DIRECTORIES)\n")
if (VFC_BUILD_TOOL)
list(APPEND configLines "include(\${CMAKE_CURRENT_LIST_DIR}/vfc-targets.cmake)\n")
endif()
file(WRITE ${configPath} ${configLines})
install(FILES ${configPath} ${versionPath} DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/VFC
COMPONENT dev)
endif()
# Documentation. (populated by built libraries)
add_subdirectory(doc)