-
Notifications
You must be signed in to change notification settings - Fork 13
/
CMakeLists.txt
176 lines (154 loc) · 4.12 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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
cmake_minimum_required(VERSION 2.8.12)
project(libmodplug)
set(VERSION "0.8.9.1")
option(BUILD_SHARED_LIBS "Build Shared Library (DLL)" OFF)
add_definitions(-DMODPLUG_BUILD)
include (CheckFunctionExists)
include (CheckIncludeFile)
include (CheckCCompilerFlag)
include (CheckCSourceCompiles)
include (TestBigEndian)
TEST_BIG_ENDIAN(WORDS_BIGENDIAN)
if(WORDS_BIGENDIAN)
add_definitions(-DWORDS_BIGENDIAN=1)
endif()
if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID MATCHES "Clang")
add_definitions(-Wall)
# check symbol visibility attributes
set(OLD_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}")
if(NOT WIN32 AND NOT CYGWIN)
set(CMAKE_REQUIRED_FLAGS "${OLD_REQUIRED_FLAGS} -Werror")
check_c_source_compiles("int foo(void) __attribute__((visibility(\"default\")));
int main(void) {return 0;}" HAVE_VISIBILITY_DEFAULT)
if(HAVE_VISIBILITY_DEFAULT)
check_c_compiler_flag(-fvisibility=hidden HAVE_VISIBILITY_HIDDEN)
endif()
endif()
set(CMAKE_REQUIRED_FLAGS "-Wl,--no-undefined")
check_c_compiler_flag("" HAVE_NO_UNDEFINED)
set(CMAKE_REQUIRED_FLAGS "${OLD_REQUIRED_FLAGS}")
endif()
include_directories(AFTER
src
src/libmodplug
${PROJECT_BINARY_DIR}
)
if(UNIX AND NOT APPLE)
find_library(MATH_LIB m)
if(MATH_LIB)
set(CMAKE_REQUIRED_LIBRARIES m)
endif()
endif()
if (WIN32)
add_definitions(-D_USE_MATH_DEFINES)
add_definitions(-DNOMINMAX)
endif()
check_include_file("stdint.h" HAVE_STDINT_H)
if (HAVE_STDINT_H)
add_definitions(-DHAVE_STDINT_H)
endif()
check_include_file("strings.h" HAVE_STRINGS_H)
if (HAVE_STRINGS_H)
add_definitions(-DHAVE_STRINGS_H)
endif()
check_function_exists("sinf" HAVE_SINF)
if(HAVE_SINF)
add_definitions(-DHAVE_SINF)
endif()
if (BUILD_SHARED_LIBS)
set (LIB_TYPE SHARED)
if (WIN32 OR CYGWIN)
add_definitions(-DDLL_EXPORT)
elseif (HAVE_VISIBILITY_HIDDEN)
add_definitions(-fvisibility=hidden)
add_definitions("-DSYM_VISIBILITY")
endif()
else ()
set(LIB_TYPE STATIC)
add_definitions(-DMODPLUG_STATIC)
endif()
add_library(modplug ${LIB_TYPE}
src/libmodplug/it_defs.h
src/libmodplug/sndfile.h
src/libmodplug/stdafx.h
src/fastmix.cpp
src/load_669.cpp
src/load_abc.cpp
src/load_amf.cpp
src/load_ams.cpp
src/load_dbm.cpp
src/load_dmf.cpp
src/load_dsm.cpp
src/load_far.cpp
src/load_it.cpp
src/load_j2b.cpp
src/load_mdl.cpp
src/load_med.cpp
src/load_mid.cpp
src/load_mod.cpp
src/load_mt2.cpp
src/load_mtm.cpp
src/load_okt.cpp
src/load_pat.cpp
src/load_pat.h
src/load_psm.cpp
src/load_ptm.cpp
src/load_s3m.cpp
src/load_stm.cpp
src/load_ult.cpp
src/load_umx.cpp
src/load_wav.cpp
src/load_xm.cpp
src/mmcmp.cpp
src/modplug.cpp
src/modplug.h
src/snd_dsp.cpp
src/snd_flt.cpp
src/snd_fx.cpp
src/sndfile.cpp
src/sndmix.cpp
src/tables.h
)
if (BUILD_SHARED_LIBS)
if(APPLE)
target_link_libraries(modplug -Wl,-undefined,error)
target_link_libraries(modplug -Wl,-compatibility_version,2.0.0)
target_link_libraries(modplug -Wl,-current_version,2.0.0)
else()
if(HAVE_NO_UNDEFINED)
target_link_libraries(modplug -Wl,--no-undefined)
endif()
set_target_properties(modplug PROPERTIES
VERSION 1.0.0 SOVERSION 1)
endif()
if(MATH_LIB)
target_link_libraries(modplug m)
endif()
endif()
# install the library:
include (GNUInstallDirs)
install(TARGETS modplug
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)
# install the headers:
install(FILES
src/modplug.h
src/libmodplug/it_defs.h
src/libmodplug/sndfile.h
src/libmodplug/stdafx.h
DESTINATION
${CMAKE_INSTALL_INCLUDEDIR}/libmodplug
)
if (NOT WIN32)
set(prefix ${CMAKE_INSTALL_PREFIX})
set(exec_prefix ${CMAKE_INSTALL_PREFIX})
set(libdir ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR})
set(includedir ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR})
configure_file(libmodplug.pc.in libmodplug.pc)
# install pkg-config file:
install(FILES "${PROJECT_BINARY_DIR}/libmodplug.pc"
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig
)
endif (NOT WIN32)