forked from hercules-390/decNumber-icu-368
-
Notifications
You must be signed in to change notification settings - Fork 6
/
CMakeLists.txt
166 lines (111 loc) · 6.02 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
#------------------------------------------------------------------------------
# Global settings
#------------------------------------------------------------------------------
cmake_minimum_required( VERSION 3.2 )
cmake_policy( SET CMP0048 NEW )
#------------------------------------------------------------------------------
# Define the project
#------------------------------------------------------------------------------
set( EXTPKG_NAME "decNumber" )
set( EXTPKG_VERS "3.68.0" )
set( EXTPKG_DESC "ANSI C General Decimal Arithmetic Library" )
project( ${EXTPKG_NAME} VERSION ${EXTPKG_VERS} LANGUAGES C )
set( PROJECT_DESCRIPTION "${EXTPKG_DESC}" CACHE PATH "Project description" FORCE )
#------------------------------------------------------------------------------
# Load some handy CMake modules
#------------------------------------------------------------------------------
if( NOT EXISTS "${CMAKE_SOURCE_DIR}/cmake/modules" )
message( FATAL_ERROR "CMake modules directory not found! ${CMAKE_SOURCE_DIR}/cmake/modules" )
else()
set( CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/modules" )
include( Vdump )
include( Trace )
endif()
#------------------------------------------------------------------------------
# Parse the build directory and set needed variables.
#------------------------------------------------------------------------------
include( ParseBinaryDir )
ParseBinaryDir()
#------------------------------------------------------------------------------
# Define package VERSION strings
#------------------------------------------------------------------------------
include( Version )
#------------------------------------------------------------------------------
# Construct a list of this project's public headers
#------------------------------------------------------------------------------
include( headers.txt )
#------------------------------------------------------------------------------
# Construct a list of this project's source files
#------------------------------------------------------------------------------
include( sources.txt )
#------------------------------------------------------------------------------
# Required headers
#------------------------------------------------------------------------------
include( CheckIncludeFile )
include( CheckHeader )
check_header( stdbool.h ) # defines HAVE_STDBOOL_H
check_header( stdint.h ) # defines HAVE_STDINT_H
#------------------------------------------------------------------------------
# Always generate the platform.h header
#------------------------------------------------------------------------------
if( NOT EXISTS ${CMAKE_SOURCE_DIR}/platform.h.in )
message( FATAL_ERROR "Unable to find platform.h.in!" )
else()
configure_file( ${CMAKE_SOURCE_DIR}/platform.h.in
${CMAKE_BINARY_DIR}/platform.h )
endif()
#------------------------------------------------------------------------------
# Update the INCLUDE directories search order
#------------------------------------------------------------------------------
include( includes.txt )
#------------------------------------------------------------------------------
# Adjust needed compile flags for this project/package
#------------------------------------------------------------------------------
include( cflags.txt )
#------------------------------------------------------------------------------
# Set the build architecture (32 bit or 64- bit)
#------------------------------------------------------------------------------
if( WIN32 )
# (the toolchain being used (i.e. vstools.cmd 32/64) defines this on Windows)
else()
if( BITNESS STREQUAL "32" )
set( CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} ${m32} -fPIC" )
set( CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} ${m32} -fPIC" )
else()
set( CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} ${m64} -fPIC" )
set( CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} ${m64} -fPIC" )
endif()
endif()
trace( CMAKE_C_FLAGS_DEBUG )
trace( CMAKE_C_FLAGS_RELWITHDEBINFO )
#------------------------------------------------------------------------------
# Define the package's build and install targets
#------------------------------------------------------------------------------
add_library( ${FULLNAME} STATIC ${${PROJECT_NAME}_SRCS} )
set_target_properties( ${FULLNAME} PROPERTIES
POSITION_INDEPENDENT_CODE TRUE
PUBLIC_HEADER "${PUBLIC_HEADERS}"
OUTPUT_NAME ${FULLNAME}
COMPILE_PDB_NAME ${FULLNAME} )
install( TARGETS ${FULLNAME}
PUBLIC_HEADER DESTINATION include
ARCHIVE DESTINATION ${LIB_INSTALL_DIR} )
#------------------------------------------------------------------------------
# Define additional files to be installed
#------------------------------------------------------------------------------
include( extra.txt )
#------------------------------------------------------------------------------
# Create an uninstall target
#------------------------------------------------------------------------------
# First, create the cmake script that will do the actual uninstall.
configure_file( "${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake" @ONLY )
# Now simply define an uninstall target that will run the above script.
add_custom_target( uninstall
COMMAND ${CMAKE_COMMAND} -P
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake" )
#------------------------------------------------------------------------------
# CMake debugging: dump variables at exit
#------------------------------------------------------------------------------
get_filename_component( CURRENT_LIST_FILE "${CMAKE_CURRENT_LIST_FILE}" NAME )
vdump( "${CURRENT_LIST_FILE}" "exit" )