-
Notifications
You must be signed in to change notification settings - Fork 141
/
Copy pathCMakeLists.txt
56 lines (50 loc) · 2.04 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
cmake_minimum_required(VERSION 3.5)
project(DMTX VERSION 0.7.8 LANGUAGES C)
set(DEFAULT_SHARED_LIBS "ON")
if(DEFINED BUILD_SHARED_LIBS AND NOT BUILD_SHARED_LIBS STREQUAL "")
set(DEFAULT_SHARED_LIBS "${BUILD_SHARED_LIBS}")
endif()
option(DMTX_SHARED "Build DMTX as shared library" "${DEFAULT_SHARED_LIBS}")
if(DMTX_SHARED)
add_library(dmtx_shared SHARED "dmtx.c")
if (MSVC)
set_target_properties(dmtx_shared PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS ON)
else()
set_target_properties(dmtx_shared PROPERTIES
VERSION ${PROJECT_VERSION}
SOVERSION ${PROJECT_VERSION_MAJOR}
)
target_link_libraries(dmtx_shared PUBLIC m)
endif()
set_target_properties(dmtx_shared PROPERTIES PUBLIC_HEADER "${CMAKE_CURRENT_SOURCE_DIR}/dmtx.h" OUTPUT_NAME "dmtx")
install(TARGETS dmtx_shared LIBRARY ARCHIVE RUNTIME PUBLIC_HEADER)
endif()
set(DEFAULT_STATIC_LIBS "ON") # XXX: ON for now, will default to OFF someday later (maybe on 0.7.9/0.8)
if(DEFINED BUILD_STATIC_LIBS AND NOT BUILD_STATIC_LIBS STREQUAL "")
set(DEFAULT_STATIC_LIBS "${BUILD_STATIC_LIBS}")
endif()
option(DMTX_STATIC "Build DMTX as static library" "${DEFAULT_STATIC_LIBS}")
if(DMTX_STATIC)
add_library(dmtx_static STATIC "dmtx.c")
if (MSVC)
set_target_properties(dmtx_static PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS ON)
else()
target_link_libraries(dmtx_static PUBLIC m)
endif()
set_target_properties(dmtx_static PROPERTIES PUBLIC_HEADER "${CMAKE_CURRENT_SOURCE_DIR}/dmtx.h" OUTPUT_NAME "dmtx")
install(TARGETS dmtx_static LIBRARY ARCHIVE RUNTIME PUBLIC_HEADER)
endif()
option(DMTX_READER_PROGRAMMING "Enable reader programming feature (adds breaking changes to API)" OFF)
if(DMTX_READER_PROGRAMMING)
add_compile_definitions(HAVE_READER_PROGRAMMING)
endif()
add_compile_definitions(VERSION="${PROJECT_VERSION}")
# Add support for tests if DMTX is the main project
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
option(BUILD_TESTING "Build tests" OFF)
if(BUILD_TESTING)
add_subdirectory("test")
endif()
include(CTest)
endif()
# vim: ft=cmake ts=2 sw=2 sts=2 et