-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
180 lines (157 loc) · 4.89 KB
/
CMakeLists.txt
File metadata and controls
180 lines (157 loc) · 4.89 KB
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
177
178
179
# xylose utility library
# Base library for various useful utilities. This project should have few
# external dependencies (boost, libxml). For many components of this project,
# only a standards compliant C++ compiler is required.
cmake_minimum_required( VERSION 2.6 )
project( xylose )
include( CTest )
################################################################################
# Obtain the xylose version
################################################################################
set( VERSION )
find_program( GIT_EXECUTABLE NAMES git )
if( GIT_EXECUTABLE )
exec_program(
${GIT_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR} ARGS describe
OUTPUT_VARIABLE VERSION
RETURN_VALUE GIT_RETVAL )
if( NOT ${GIT_RETVAL} EQUAL 0 )
# Something went wrong, fall back on other methods.
# We still didn't find a version, so it's really unknown.
set( VERSION "xylose-unknownversion" )
endif()
endif()
message( STATUS "xylose VERSION: ${VERSION}" )
if( MSVC )
set( USE_WINSOCK TRUE )
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/src/xylose/compat/config.hpp.in
${CMAKE_CURRENT_BINARY_DIR}/src/xylose/compat/config.hpp
)
endif()
# include the current directory for framework style includes
set( ${PROJECT_NAME}_INCLUDE_DIRS
${CMAKE_CURRENT_SOURCE_DIR}/src
${CMAKE_CURRENT_BINARY_DIR}/src
)
set( ${PROJECT_NAME}_DEFINITIONS -DXYLOSE_VERSION=${VERSION} )
add_definitions( ${${PROJECT_NAME}_DEFINITIONS} )
include_directories( ${${PROJECT_NAME}_INCLUDE_DIRS} )
set( ${PROJECT_NAME}_HEADERS
src/xylose/AbstractFactory.hpp
src/xylose/bits.hpp
src/xylose/data_set.h
src/xylose/detail/Iterator.hpp
src/xylose/Factory.hpp
src/xylose/Index.hpp
src/xylose/logger.h
src/xylose/pool_allocator.hpp
src/xylose/power.h
src/xylose/random/Crappy.hpp
src/xylose/random/detail/RandBase.hpp
src/xylose/random/Kiss.hpp
src/xylose/random/MersenneTwister.hpp
src/xylose/segmented_vector.hpp
src/xylose/Singleton.hpp
src/xylose/Stack.hpp
src/xylose/strutil.h
src/xylose/Swap.hpp
src/xylose/SyncLock.h
src/xylose/Timer.h
src/xylose/TypedFactory.hpp
src/xylose/upper_triangle.h
src/xylose/Vector.h
src/xylose/compat/unistd.hpp
src/xylose/compat/stdio.hpp
src/xylose/compat/compat.hpp
src/xylose/compat/sys/times.hpp
src/xylose/compat/sys/time.hpp
src/xylose/compat/math.hpp
src/xylose/compat/strings.hpp
src/xylose/xml/Context.h
src/xylose/xml/Doc.h
src/xylose/xml/error.h
src/xylose/xml/physical_parse.h
src/xylose/xml/vector_parse.h
src/xylose/XSTR.h
)
set( ${PROJECT_NAME}_SOURCES
src/xylose/Index.cpp
src/xylose/logger.c
src/xylose/power.c
src/xylose/segmented_vector.cpp
src/xylose/Singleton.cpp
src/xylose/Stack.cpp
src/xylose/Timer.cpp
src/xylose/compat/sys/time.cpp
src/xylose/compat/math.c
)
add_library( ${PROJECT_NAME}
${${PROJECT_NAME}_HEADERS}
${${PROJECT_NAME}_SOURCES}
)
LIST(APPEND targets_to_install ${PROJECT_NAME})
find_package( appspack QUIET )
find_package( LibXml2 )
find_package( Threads )
find_package( Boost COMPONENTS program_options )
if ( APPSPACK_FOUND AND LIBXML2_FOUND AND
THREADS_FOUND AND CMAKE_USE_PTHREADS_INIT AND
Boost_PROGRAM_OPTIONS_FOUND )
add_definitions(
${appspack_DEFINITIONS}
${LIBXML2_DEFINITIONS}
${Boost_DEFINITIONS}
)
include_directories(
${appspack_INCLUDE_DIRS}
${LIBXML2_INCLUDE_DIR}
${Boost_INCLUDE_DIRS}
)
enable_language( Fortran )
add_executable( appspack_pthread
src/xylose/fit/appspack/appsPack.cpp
${appspack_DUMMY_FORTRAN_FILE}
)
target_link_libraries( appspack_pthread
${PROJECT_NAME}
${appspack_LIBRARIES}
${LIBXML2_LIBRARIES}
${Boost_PROGRAM_OPTIONS_LIBRARY}
)
if( THREADS_HAVE_PTHREAD_ARG )
set_source_files_properties(
src/xylose/fit/appspack/appsPack.cpp
COMPILE_FLAGS ${CMAKE_THREAD_LIBS_INIT}
)
endif()
set_target_properties( appspack_pthread
PROPERTIES
LINK_FLAGS ${CMAKE_THREAD_LIBS_INIT}
)
LIST(APPEND targets_to_install appspack_pthread)
endif()
# Stuff to help a simple local find module for this project
MESSAGE(STATUS "Creating xylose-config.cmake")
FILE(WRITE
${CMAKE_BINARY_DIR}/xylose-config.cmake
"set( ${PROJECT_NAME}_VERSION \n"
" ${VERSION}\n"
")\n"
"set( ${PROJECT_NAME}_DEFINITIONS \n"
" ${${PROJECT_NAME}_DEFINITIONS}\n"
")\n"
"set( ${PROJECT_NAME}_INCLUDE_DIRS\n"
" ${${PROJECT_NAME}_INCLUDE_DIRS}\n"
")\n"
"set( ${PROJECT_NAME}_${PROJECT_NAME}_LIBRARY\n"
" ${PROJECT_NAME}\n"
")\n"
)
install( TARGETS ${targets_to_install}
ARCHIVE DESTINATION lib/static
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin
)
# add source directory to get the unit tests recursively
add_subdirectory( src )