forked from randy408/libspng
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
60 lines (44 loc) · 1.69 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
cmake_minimum_required(VERSION 3.0)
project(libspng C)
set(SPNG_MAJOR 0)
set(SPNG_MINOR 6)
set(SPNG_REVISION 2)
set(SPNG_VERSION ${SPNG_MAJOR}.${SPNG_MINOR}.${SPNG_REVISION})
option(ENABLE_OPT "Enable architecture-specific optimizations" ON)
option(SPNG_SHARED "Build shared lib" ON)
option(SPNG_STATIC "Build static lib" ON)
include(GNUInstallDirs)
find_package(ZLIB REQUIRED)
include_directories(${ZLIB_INCLUDE_DIRS})
set(spng_SOURCES spng/spng.c)
if(NOT CMAKE_HOST_WIN32)
set(spng_LIBS -lm ${ZLIB_LIBRARIES})
else()
set(spng_LIBS ${ZLIB_LIBRARIES})
endif()
if(NOT ENABLE_OPT)
add_definitions( -DSPNG_DISABLE_OPT=1 )
endif()
if(SPNG_SHARED)
add_library(spng SHARED ${spng_SOURCES})
target_link_libraries(spng ${spng_LIBS})
install(TARGETS spng DESTINATION lib)
add_executable(example examples/example.c)
target_include_directories(example PRIVATE ${PROJECT_SOURCE_DIR}/spng)
target_link_libraries(example spng ${spng_LIBS})
endif()
if(SPNG_STATIC)
add_library(spng_static STATIC ${spng_SOURCES})
target_compile_definitions(spng_static PUBLIC SPNG_STATIC)
install(TARGETS spng_static DESTINATION lib)
endif()
install(FILES spng/spng.h DESTINATION include)
if(NOT CMAKE_HOST_WIN32 OR CYGWIN OR MINGW)
set(prefix ${CMAKE_INSTALL_PREFIX})
set(exec_prefix ${CMAKE_INSTALL_PREFIX})
set(libdir ${CMAKE_INSTALL_FULL_LIBDIR})
set(includedir ${CMAKE_INSTALL_FULL_INCLUDEDIR})
set(LIBS "-lz -lm")
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/tests/libspng.pc.in ${CMAKE_CURRENT_BINARY_DIR}/tests/libspng.pc @ONLY)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/tests/libspng.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
endif()