-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
117 lines (102 loc) · 3.54 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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
# CMakeLists.txt for liborigin
cmake_minimum_required(VERSION 3.16.3)
project( liborigin
VERSION 3.0.0
LANGUAGES CXX
)
set( CMAKE_CXX_STANDARD 17 )
set( CMAKE_CXX_STANDARD_REQUIRED TRUE )
set( CMAKE_CXX_EXTENSIONS OFF )
if( MSVC )
# /wd4456 /wd4458 Silent "declaration of %1 hides %2 ..."
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc /W4 /permissive- /wd4456 /wd4458" )
add_compile_definitions( _CRT_SECURE_NO_WARNINGS
_SILENCE_CXX17_OLD_ALLOCATOR_MEMBERS_DEPRECATION_WARNING )
if( CMAKE_CXX_COMPILER_ID STREQUAL "Clang" )
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-nonportable-include-path" )
else()
add_compile_options( "/MP" )
endif()
else()
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fexceptions -Wall -Wextra -pedantic" )
set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -pedantic" )
endif()
# compile-time configuration variables to be linked in
configure_file(config.h.in ${CMAKE_CURRENT_BINARY_DIR}/config.h)
include_directories(${CMAKE_CURRENT_BINARY_DIR})
# source files
set (sources
OriginFile.cpp
OriginParser.cpp
OriginAnyParser.cpp
)
# header files for development
set (devel-headers
OriginObj.h
OriginFile.h
OriginParser.h
tree.hh
)
# allow for installation of individual targets
set(CMAKE_SKIP_INSTALL_ALL_DEPENDENCY true)
# object library
add_library (origin OBJECT ${sources})
set_target_properties(origin PROPERTIES POSITION_INDEPENDENT_CODE ON)
# inform on log setting
if (DEFINED GENERATE_CODE_FOR_LOG)
message("File parsing will be logged.")
target_compile_definitions(origin PRIVATE GENERATE_CODE_FOR_LOG=${GENERATE_CODE_FOR_LOG})
else()
message("File parsing will NOT be logged. Define GENERATE_CODE_FOR_LOG to activate logging.")
endif ()
# Static library
add_library (origin_static STATIC $<TARGET_OBJECTS:origin>)
set_target_properties(origin_static PROPERTIES OUTPUT_NAME "origin" )
if( "${CMAKE_SOURCE_DIR}" STREQUAL "${PROJECT_SOURCE_DIR}" )
include(GNUInstallDirs)
# Shared library
add_library( origin_shared SHARED $<TARGET_OBJECTS:origin>)
set_target_properties(origin_shared PROPERTIES
OUTPUT_NAME "origin"
VERSION ${PROJECT_VERSION}
SOVERSION ${PROJECT_VERSION_MAJOR}
)
# Generate a pkg-config file matching this config
configure_file( "liborigin.pc.in" "liborigin.pc" @ONLY )
if(ENABLE_TOOLS)
# command line util
add_executable(opj2dat opj2dat.cpp)
target_link_libraries (opj2dat origin_shared)
endif ()
# install libraries
install( TARGETS origin_shared origin_static
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
)
# install headers
install(FILES ${devel-headers} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/liborigin)
# install pkg-config file
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/liborigin.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
#
if(ENABLE_TOOLS)
install(TARGETS opj2dat DESTINATION ${CMAKE_INSTALL_BINDIR} OPTIONAL)
endif ()
# documentation
install(FILES COPYING FORMAT README
DESTINATION ${CMAKE_INSTALL_DOCDIR}
OPTIONAL
)
# Doxygen
configure_file(doc/Doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile)
find_package(Doxygen)
if(DOXYGEN_FOUND)
add_custom_target(doc ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
set_property(DIRECTORY APPEND PROPERTY ADDITIONAL_MAKE_CLEAN_FILES ${CMAKE_CURRENT_BINARY_DIR}/html)
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/html
DESTINATION ${CMAKE_INSTALL_DOCDIR}
OPTIONAL
)
endif()
endif()