-
Notifications
You must be signed in to change notification settings - Fork 119
/
CMakeLists.txt
82 lines (66 loc) · 2.33 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
cmake_minimum_required(VERSION 2.8.12)
# Compiler requirements
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
project(tinyply LANGUAGES CXX)
set(PROJECT_VERSION 2.3)
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/source")
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/third-party")
if(NOT CMAKE_DEBUG_POSTFIX)
set(CMAKE_DEBUG_POSTFIX "d")
endif()
# Library
set(SHARED_LIB false CACHE BOOL "Build as shared library")
if(${SHARED_LIB})
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
add_library(tinyply SHARED source/tinyply.cpp source/tinyply.h)
else()
add_library(tinyply STATIC source/tinyply.cpp source/tinyply.h)
endif()
set(BUILD_TESTS false CACHE BOOL "Build tests")
# Example Application
add_executable(example source/example.cpp)
target_link_libraries(example PRIVATE tinyply)
# Test Application
if(${BUILD_TESTS})
add_executable(tests source/tests.cpp)
target_link_libraries(tests PRIVATE tinyply)
endif()
# pkg-config support
set(generated_dir "${CMAKE_CURRENT_BINARY_DIR}/generated")
if(UNIX)
configure_file(cmake/tinyply.pc.in ${generated_dir}/tinyply.pc @ONLY)
install(FILES "${generated_dir}/tinyply.pc" DESTINATION lib/pkgconfig)
endif()
# CMake package config support
include(CMakePackageConfigHelpers)
set(config_install_dir "lib/cmake/${PROJECT_NAME}")
set(version_config "${generated_dir}/${PROJECT_NAME}ConfigVersion.cmake")
set(project_config "${generated_dir}/${PROJECT_NAME}Config.cmake")
set(targets_export_name "${PROJECT_NAME}Targets")
set(namespace "")
include(GNUInstallDirs)
write_basic_package_version_file(
"${version_config}"
VERSION ${PROJECT_VERSION}
COMPATIBILITY SameMajorVersion
)
configure_package_config_file(
"cmake/Config.cmake.in"
"${project_config}"
INSTALL_DESTINATION "${config_install_dir}"
)
# Install
install(TARGETS tinyply EXPORT ${targets_export_name}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
install(FILES source/tinyply.h
DESTINATION include)
install(FILES "${project_config}" "${version_config}"
DESTINATION "${config_install_dir}")
install(EXPORT "${targets_export_name}"
NAMESPACE "${namespace}"
DESTINATION "${config_install_dir}")