forked from rogersce/cnpy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
47 lines (42 loc) · 1.17 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
cmake_minimum_required(VERSION 3.25 FATAL_ERROR)
if(COMMAND cmake_policy)
cmake_policy(SET CMP0003 NEW)
endif()
project(cnpy LANGUAGES CXX)
find_package(ZLIB REQUIRED)
add_library(cnpy STATIC cnpy.cpp)
add_library(cnpy::cnpy ALIAS cnpy)
target_link_libraries(cnpy PUBLIC ZLIB::ZLIB)
target_compile_features(cnpy PRIVATE cxx_std_11)
target_include_directories(
cnpy
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<INSTALL_INTERFACE:include>
)
if(NOT MSVC)
target_compile_options(cnpy PRIVATE -Wall -Wextra)
endif()
if(NOT DEFINED CNPY_INSTALL)
if(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
set(CNPY_INSTALL TRUE)
else()
set(CNPY_INSTALL FALSE)
endif()
endif()
if(CNPY_INSTALL)
install(
TARGETS "cnpy"
ARCHIVE DESTINATION lib
PERMISSIONS
OWNER_READ OWNER_WRITE OWNER_EXECUTE
GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
)
install(FILES cnpy.h DESTINATION include)
install(
EXPORT cnpy-targets
FILE cnpy-targets.cmake
DESTINATION lib/cmake/cnpy
)
install(TARGETS cnpy EXPORT cnpy-targets DESTINATION lib)
endif()