-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
93 lines (73 loc) · 2.57 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
cmake_minimum_required(VERSION 3.21...3.30)
# Default build type value.
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the build type")
project(pxr-arch
HOMEPAGE_URL "https://github.com/untwine/pxr-arch"
LANGUAGES C CXX
)
include(GNUInstallDirs)
if (NOT "${CMAKE_CXX_STANDARD}")
set(CMAKE_CXX_STANDARD 17 CACHE STRING "Default C++ standard")
endif()
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
# Default options.
option(BUILD_TESTS "Build tests" ON)
option(BUILD_DOCS "Build documentation" ON)
option(BUILD_SHARED_LIBS "Build Shared Library" ON)
option(ENABLE_PRECOMPILED_HEADERS "Enable precompiled headers." OFF)
if (NOT BUILD_SHARED_LIBS)
add_compile_definitions(PXR_STATIC)
endif()
if (WIN32)
# Make sure WinDef.h does not define min and max macros which
# will conflict with std::min() and std::max().
add_definitions(-DNOMINMAX)
# Exclude headers from unnecessary Windows APIs to improve build
# times and avoid annoying conflicts with macros defined in those
# headers.
add_definitions(-DWIN32_LEAN_AND_MEAN)
# The /Zc:inline option strips out the "arch_ctor_<name>" symbols used for
# library initialization by ARCH_CONSTRUCTOR starting in Visual Studio 2019,
# causing release builds to fail. Disable the option for this and later
# versions.
#
# For more details, see:
# https://developercommunity.visualstudio.com/content/problem/914943/zcinline-removes-extern-symbols-inside-anonymous-n.html
if (MSVC_VERSION GREATER_EQUAL 1920)
set(CMAKE_CXX_FLAGS "/Zc:inline- ${CMAKE_CXX_FLAGS}")
else()
set(CMAKE_CXX_FLAGS "/Zc:inline ${CMAKE_CXX_FLAGS}")
endif()
endif()
# Update build type from environment for CMake < 3.22
if (DEFINED ENV{CMAKE_BUILD_TYPE})
set(CMAKE_BUILD_TYPE $ENV{CMAKE_BUILD_TYPE}
CACHE STRING "Specifies the build type" FORCE)
endif()
find_package(Threads REQUIRED)
add_subdirectory(src)
# Build and setup tests if required.
if (BUILD_TESTS)
find_package(GTest REQUIRED)
include(GoogleTest)
enable_testing()
add_subdirectory(test)
endif()
# Build documentation if required.
if (BUILD_DOCS)
find_package(Sphinx 1.8.6 REQUIRED)
find_package(Doxygen 1.8.5 REQUIRED)
add_subdirectory(doc)
endif()
include(CMakePackageConfigHelpers)
configure_package_config_file(
"cmake/pxr-arch-config.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/pxr-arch-config.cmake"
INSTALL_DESTINATION share/cmake/pxr-arch
)
install(
FILES
"${CMAKE_CURRENT_BINARY_DIR}/pxr-arch-config.cmake"
DESTINATION share/cmake/pxr-arch
)