Skip to content

Commit 9106258

Browse files
committed
Revised CMakeLists.txt (take 2) with changes suggested by Pavel Koshevoy
- Also works on MacOSX
1 parent 8ead181 commit 9106258

File tree

1 file changed

+58
-7
lines changed

1 file changed

+58
-7
lines changed

CMakeLists.txt

Lines changed: 58 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1+
cmake_minimum_required(VERSION 2.8.0)
2+
13
project(libmodplug)
4+
add_definitions(-DMODPLUG_BUILD)
25

3-
cmake_minimum_required(VERSION 2.8.0)
6+
include (CheckFunctionExists)
47

58
include_directories(AFTER
69
src
@@ -11,8 +14,40 @@ include_directories(AFTER
1114
if (WIN32)
1215
add_definitions(-D_USE_MATH_DEFINES)
1316
add_definitions(-DNOMINMAX)
14-
endif (WIN32)
17+
endif()
18+
19+
if (WIN32 AND NOT (MINGW OR MSYS))
20+
set(MSINTTYPES_PATH "$ENV{MSINTTYPES_PATH}" CACHE PATH "search path for inttypes.h and stdint.h")
21+
22+
find_path(STDINT_INCLUDE_DIR
23+
stdint.h
24+
PATHS
25+
${MSINTTYPES_PATH})
26+
27+
if (STDINT_INCLUDE_DIR)
28+
add_definitions(-DHAVE_STDINT_H)
29+
include_directories(AFTER "${STDINT_INCLUDE_DIR}")
30+
endif()
1531

32+
find_path(INTTYPES_INCLUDE_DIR
33+
inttypes.h
34+
PATHS
35+
${MSINTTYPES_PATH})
36+
37+
if (INTTYPES_INCLUDE_DIR)
38+
add_definitions(-DHAVE_INTTYPES_H)
39+
include_directories(AFTER "${INTTYPES_INCLUDE_DIR}")
40+
endif()
41+
42+
if (NOT STDINT_INCLUDE_DIR OR NOT INTTYPES_INCLUDE_DIR)
43+
message(WARNING
44+
"Compilation may fail if inttypes.h is not natively supported by the compiler."
45+
"You can get inttypes.h from http://code.google.com/p/msinttypes/")
46+
endif()
47+
endif()
48+
49+
check_function_exists("setenv" HAVE_SETENV)
50+
check_function_exists("sinf" HAVE_SINF)
1651

1752
# Allow the developer to select if Dynamic or Static libraries are built
1853
option(BUILD_SHARED_LIBS "Build Shared Library (DLL)" OFF)
@@ -24,6 +59,9 @@ if (BUILD_SHARED_LIBS)
2459
# User wants to build Dynamic Libraries,
2560
# so change the LIB_TYPE variable to CMake keyword 'SHARED'
2661
set (LIB_TYPE SHARED)
62+
add_definitions(-DDLL_EXPORT)
63+
else (BUILD_SHARED_LIBS)
64+
add_definitions(-DMODPLUG_STATIC)
2765
endif (BUILD_SHARED_LIBS)
2866

2967
add_library(modplug ${LIB_TYPE}
@@ -84,11 +122,24 @@ install(FILES
84122
include/libmodplug
85123
)
86124

87-
# fill in the blanks in libmodplug.pc.in
88125
set(VERSION "0.8.8.5")
89-
configure_file(libmodplug.pc.in-for-cmake libmodplug.pc)
90126

91-
# install pkg-config file:
92-
install(FILES "${PROJECT_BINARY_DIR}/libmodplug.pc"
93-
DESTINATION lib/pkgconfig
127+
if(HAVE_SETENV)
128+
add_definitions(-DHAVE_SETENV)
129+
endif(HAVE_SETENV)
130+
if(HAVE_SINF)
131+
add_definitions(-DHAVE_SINF)
132+
endif(HAVE_SINF)
133+
134+
if (NOT WIN32)
135+
set(prefix "${CMAKE_INSTALL_PREFIX}")
136+
set(exec_prefix "${CMAKE_INSTALL_PREFIX}")
137+
set(libdir "${CMAKE_INSTALL_PREFIX}/lib")
138+
set(includedir "${CMAKE_INSTALL_PREFIX}/include")
139+
configure_file(libmodplug.pc.in libmodplug.pc)
140+
141+
# install pkg-config file:
142+
install(FILES "${PROJECT_BINARY_DIR}/libmodplug.pc"
143+
DESTINATION lib/pkgconfig
94144
)
145+
endif (NOT WIN32)

0 commit comments

Comments
 (0)