-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathCMakeLists.txt
108 lines (94 loc) · 3.55 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
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
PROJECT(libdirtrav)
# parameters
OPTION(BUILD_STATIC "Build static libraries" ON)
OPTION(BUILD_SHARED "Build shared libraries" ON)
OPTION(BUILD_TOOLS "Build tools" ON)
IF(WIN32)
OPTION(WITH_WIDE "Also build UTF-16 library (libdirtravw)" OFF)
OPTION(FORCE_OPENDIR "Force using opendir() instead of Windows API" OFF)
ELSE()
SET(WITH_WIDE OFF)
ENDIF()
# conditions
IF(NOT BUILD_STATIC AND NOT BUILD_SHARED)
MESSAGE(FATAL_ERROR "Cannot build with both BUILD_STATIC and BUILD_SHARED disabled")
ENDIF()
# Doxygen
FIND_PACKAGE(Doxygen)
OPTION(BUILD_DOCUMENTATION "Create and install API documentation (requires Doxygen)" ${DOXYGEN_FOUND})
# build parameters
#SET(CMAKE_C_FLAGS "-Wall")
IF(FORCE_OPENDIR)
SET(FORCE_OPENDIR_DEF ${CMAKE_C_FLAGS} "FORCE_OPENDIR")
ELSE()
SET(FORCE_OPENDIR_DEF ${CMAKE_C_FLAGS} "")
ENDIF()
INCLUDE_DIRECTORIES(include)
# build definitions
SET(ALLTARGETS)
SET(LINKTYPES)
IF(BUILD_STATIC)
LIST(APPEND LINKTYPES "STATIC")
ENDIF()
IF(BUILD_SHARED)
LIST(APPEND LINKTYPES "SHARED")
ENDIF()
FOREACH(LINKTYPE ${LINKTYPES})
ADD_LIBRARY(dirtrav_${LINKTYPE} ${LINKTYPE} src/dirtrav.c)
SET_TARGET_PROPERTIES(dirtrav_${LINKTYPE} PROPERTIES DEFINE_SYMBOL "BUILD_DIRTRAV_DLL")
SET_TARGET_PROPERTIES(dirtrav_${LINKTYPE} PROPERTIES COMPILE_DEFINITIONS "DIRTRAV_GENERATE;${LINKTYPE};${FORCE_OPENDIR_DEF}")
SET_TARGET_PROPERTIES(dirtrav_${LINKTYPE} PROPERTIES OUTPUT_NAME dirtrav)
TARGET_INCLUDE_DIRECTORIES(dirtrav_${LINKTYPE} PRIVATE lib)
#TARGET_LINK_LIBRARIES(dirtrav_${LINKTYPE} ${ANYZIP_LIBRARIES} ${EXPAT_LIBRARIES})
SET(ALLTARGETS ${ALLTARGETS} dirtrav_${LINKTYPE})
IF(WITH_WIDE)
ADD_LIBRARY(dirtravw_${LINKTYPE} ${LINKTYPE} src/dirtrav.c)
SET_TARGET_PROPERTIES(dirtravw_${LINKTYPE} PROPERTIES DEFINE_SYMBOL "BUILD_DIRTRAV_DLL")
SET_TARGET_PROPERTIES(dirtravw_${LINKTYPE} PROPERTIES COMPILE_DEFINITIONS "DIRTRAV_GENERATE_WIDE;${LINKTYPE};${FORCE_OPENDIR_DEF}")
SET_TARGET_PROPERTIES(dirtravw_${LINKTYPE} PROPERTIES OUTPUT_NAME dirtravw)
TARGET_INCLUDE_DIRECTORIES(dirtravw_${LINKTYPE} PRIVATE lib)
#TARGET_LINK_LIBRARIES(dirtravw_${LINKTYPE} ${ANYZIP_LIBRARIES} ${EXPATW_LIBRARIES})
SET(ALLTARGETS ${ALLTARGETS} dirtravw_${LINKTYPE})
ENDIF()
SET(EXELINKTYPE ${LINKTYPE})
ENDFOREACH()
IF(BUILD_TOOLS)
ADD_EXECUTABLE(tree src/tree.c)
TARGET_LINK_LIBRARIES(tree dirtrav_${EXELINKTYPE})
LIST(APPEND ALLTARGETS tree)
ADD_EXECUTABLE(rdir src/rdir.c)
TARGET_LINK_LIBRARIES(rdir dirtrav_${EXELINKTYPE})
LIST(APPEND ALLTARGETS rdir)
ADD_EXECUTABLE(folderstats src/folderstats.c)
TARGET_LINK_LIBRARIES(folderstats dirtrav_${EXELINKTYPE})
LIST(APPEND ALLTARGETS folderstats)
ENDIF()
IF(BUILD_DOCUMENTATION)
IF(NOT DOXYGEN_FOUND)
MESSAGE(FATAL_ERROR "Doxygen is needed to build the documentation.")
ENDIF()
ADD_CUSTOM_TARGET(doc ALL
COMMAND ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/doc/Doxyfile
#WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMENT "Generating API documentation with Doxygen"
VERBATIM
)
INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/doc/man
DESTINATION .
)
INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/doc/html
DESTINATION share/libdirtrav
)
ENDIF()
# installation specifications
INSTALL(TARGETS ${ALLTARGETS}
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin
)
INSTALL(DIRECTORY include/
DESTINATION include
FILES_MATCHING PATTERN "dirtrav*.h"
)