CMakeLists.txt 9.76 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# Spell-QTL  Software suite for the QTL analysis of modern datasets.
# Copyright (C) 2016,2017  Damien Leroux <damien.leroux@inra.fr>, Sylvain Jasson <sylvain.jasson@inra.fr>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

17
cmake_minimum_required(VERSION 3.0)
damien's avatar
damien committed
18
19
project(spell_qtl)

20
21
22
#LIST(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/CMake")
#INCLUDE(pandocology)

23
find_package(Boost 1.56.0 REQUIRED)
24
#set(CMAKE_CONFIGURATION_TYPES Debug Release CACHE INTERNAL FORCE)
damien's avatar
damien committed
25

26
27
set(CMAKE_VERBOSE_MAKEFILE ON)

28
29
set(BUILD_FOR_DEPLOYMENT FALSE CACHE BOOL "Link against static libc++ and use minimal symbol version where possible")

30
31
MESSAGE(STATUS "CMAKE VERSION ${CMAKE_VERSION}")
MESSAGE(STATUS "${CMAKE_CURRENT_SOURCE_DIR}")
damien's avatar
damien committed
32
33

execute_process(
34
35
        COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/get_patch_number.sh
        WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
damien's avatar
damien committed
36
37
38
39
40
41
42
43
44
45
46
        OUTPUT_VARIABLE VERSION_PATCH
        OUTPUT_STRIP_TRAILING_WHITESPACE
)

execute_process(
        COMMAND git tag
        COMMAND tail -1
        OUTPUT_VARIABLE LAST_TAG
        OUTPUT_STRIP_TRAILING_WHITESPACE
)

47
STRING(REGEX MATCHALL "[^.]+" VERSION "${LAST_TAG}")
damien's avatar
damien committed
48
49
50
51
52
53
54
55
56
57

MESSAGE(STATUS "LAST TAG ${LAST_TAG}")
MESSAGE(STATUS "VERSION ${VERSION}")

LIST(GET VERSION 0 VERSION_MAJOR)
LIST(GET VERSION 1 VERSION_MINOR)

set(CMAKE_CXX_STANDARD 11)

SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wextra -Wall -Wno-unused-parameter -pthread -fPIC")
58
SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS} -O2 -DNDEBUG -DEIGEN_NO_DEBUG")
59
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS} -O0 -ggdb")
damien's avatar
damien committed
60
61
62
63
64
65
66

add_definitions(-DEIGEN_NO_DEPRECATED_WARNING -DVERSION_MAJOR=\"${VERSION_MAJOR}\" -DVERSION_MINOR=\"${VERSION_MINOR}\" -DVERSION_PATCH=\"${VERSION_PATCH}\")

MESSAGE(STATUS "CXX FLAGS ${CMAKE_CXX_FLAGS}")

find_library(EXPAT_LIBRARY_NAMES expat)
find_path(EXPAT_INCLUDE_DIR expat.h HINTS /usr/include /usr/local/include /usr/include/expat/ /usr/local/include/expat/)
Damien Leroux's avatar
Damien Leroux committed
67
# find_path(X2C_INCLUDE_DIR x2c/x2c.h HINTS /usr/include/ /usr/local/include/ /home/daleroux/include/)
68
find_path(EIGEN_INCLUDE_DIR Eigen/Eigen HINTS /usr/include /usr/local/include /usr/include/eigen3/ /usr/local/include/eigen3/ /home/daleroux/include/eigen3/)
damien's avatar
damien committed
69
70

include_directories(AFTER 3rd-party/ThreadPool)
damien's avatar
damien committed
71
include_directories(AFTER ${CMAKE_SOURCE_DIR}/include/ ${CMAKE_SOURCE_DIR}/include/input/ ${CMAKE_SOURCE_DIR}/include/bayes/ ${EIGEN_INCLUDE_DIR})
Damien Leroux's avatar
Damien Leroux committed
72
73
include_directories(SYSTEM /usr/include ${Boost_INCLUDE_DIRS} ${EXPAT_INCLUDE_DIR})
include_directories(AFTER /usr/include ${Boost_INCLUDE_DIRS} ${EXPAT_INCLUDE_DIR})
damien's avatar
damien committed
74

75
76
77
78
79
80
81
82
if(${BUILD_FOR_DEPLOYMENT})
    set(libstdcpp ${CMAKE_BINARY_DIR}/libstdc++.a)
else(${BUILD_FOR_DEPLOYMENT})
    set(libstdcpp "")
endif(${BUILD_FOR_DEPLOYMENT})

MESSAGE(STATUS "libstdcpp = ${libstdcpp}")

damien's avatar
damien committed
83
84
85
86
87
88
89
set(SPELL_PEDIGREE_SRC
        src/static_data.cc
        src/pedigree/main.cc
        src/pedigree/cli.cc
)

set(SPELL_MARKER_SRC
Damien Leroux's avatar
Damien Leroux committed
90
91
        src/input/read_mark.cc src/input/read_map.cc
        # src/input/design.cc src/input/xml/xml_design.cc src/input/xml/xml_format.cc
damien's avatar
damien committed
92
93
94
95
96
        src/static_data.cc
        src/bayes/main.cc src/bayes/dispatch.cc src/bayes/jobs.cc src/bayes/cli.cc
)

set(SPELL_QTL_SRC
Damien Leroux's avatar
Damien Leroux committed
97
98
        src/input/read_map.cc src/input/read_trait.cc src/input/read_settings.cc src/input/ld_matrices.cc
#         src/input/xml/xml_format.cc src/input/xml/xml_settings.cc
damien's avatar
damien committed
99
100
101
102
        src/static_data.cc src/main.cc src/beta_gamma.cc
        src/computations/basic_data.cc src/computations/probabilities.cc src/computations/model.cc src/computations/frontends.cc
)

103
104
105
106
107
108
109
110
111
112
113
114
MESSAGE(STATUS "spell-pedigree src = ${SPELL_PEDIGREE_SRC}")


#get_cmake_property(_variableNames VARIABLES)
#foreach (_variableName ${_variableNames})
#    message(STATUS "${_variableName}=${${_variableName}}")
#endforeach()

if(${BUILD_FOR_DEPLOYMENT})
    add_executable(spell-pedigree ${SPELL_PEDIGREE_SRC} ${libstdcpp})
    add_executable(spell-marker ${SPELL_MARKER_SRC})
    add_executable(spell-qtl ${SPELL_QTL_SRC} ${libstdcpp})
115
116
117
118
119
120
121
122
    add_custom_command(
        OUTPUT glibc.h libstdc++.a
        COMMAND ${CMAKE_SOURCE_DIR}/deploy/make_old_libc_header.sh
        WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
    add_custom_command(
        OUTPUT libgmp.a
        COMMAND ${CMAKE_SOURCE_DIR}/deploy/compile_gmp.sh ${CMAKE_BINARY_DIR}/glibc.h ${CMAKE_BINARY_DIR}
        WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/deploy)
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
    add_custom_target(glibc.h)

    add_library(gmp INTERFACE IMPORTED)
    add_custom_target(pouet ALL DEPENDS ${CMAKE_BINARY_DIR}/libgmp.a)
    
    SET_SOURCE_FILES_PROPERTIES(${SPELL_PEDIGREE_SRC} ${SPELL_MARKER_SRC} ${SPELL_QTL_SRC}
            PROPERTIES
            OBJECT_DEPENDS glibc.h
            COMPILE_FLAGS "-include ${CMAKE_BINARY_DIR}/glibc.h -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0")

    #add_dependencies(stdc++ libstdc++.a)
    #add_dependencies(gmp libgmp.a)
    add_dependencies(spell-pedigree glibc.h)
    add_dependencies(spell-marker glibc.h pouet)
    add_dependencies(spell-qtl glibc.h)

    MESSAGE(STATUS " PROUT ${libstdcpp}")
    
    set(CMAKE_EXE_LINKER_FLAGS "-include ${CMAKE_BINARY_DIR}/glibc.h -rdynamic -static-libgcc")

    target_link_libraries(spell-marker ${libstdcpp} ${CMAKE_BINARY_DIR}/libgmp.a)
    target_link_libraries(spell-qtl ${libstdcpp})
    target_link_libraries(spell-pedigree ${libstdcpp})
else()
    add_executable(spell-pedigree ${SPELL_PEDIGREE_SRC})
    add_executable(spell-marker ${SPELL_MARKER_SRC})
    add_executable(spell-qtl ${SPELL_QTL_SRC})
    set(CMAKE_EXE_LINKER_FLAGS "-rdynamic")
endif()
damien's avatar
damien committed
152

153
target_link_libraries(spell-marker dl gmp)
154
target_link_libraries(spell-qtl expat dl rt)
damien's avatar
damien committed
155
156

SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
157

158
159
160
161
162
163
164
165
166
167
168
169
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/doc)
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/doc/man)

add_custom_target(manpages ALL)

function(add_manpage manpage)
    add_custom_command(
            TARGET manpages
            PRE_BUILD
            COMMAND pandoc --to man --standalone ${CMAKE_SOURCE_DIR}/doc/man/${manpage}.md -o ${manpage}
            WORKING_DIRECTORY doc/man
            COMMENT "Generating manpage ${manpage}")
170
171
    INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/doc/man/${manpage}
            DESTINATION share/man/man1)
172
173
174
175
176
endfunction()

add_manpage(spell-pedigree.1)
add_manpage(spell-marker.1)
add_manpage(spell-qtl.1)
damien's avatar
damien committed
177
add_manpage(spell-qtl-examples.1)
178

179
add_custom_target(user_manual.pdf ALL COMMAND ./build_manual.sh ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR} WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/deploy)
Damien Leroux's avatar
Damien Leroux committed
180
add_dependencies(user_manual.pdf spell-pedigree spell-marker spell-qtl manpages)
181

182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
#add_custom_command(OUTPUT spell-marker.1
#        COMMAND pandoc -t man ${CMAKE_SOURCE_DIR}/doc/man/spell-marker.1.md -o spell-marker.1
#        MAIN_DEPENDENCY ${CMAKE_SOURCE_DIR}/doc/man/spell-marker.1.md
#        WORKING_DIRECTORY doc/man)


#add_document(
#    spell-marker.1
#    SOURCES
#        ${CMAKE_SOURCE_DIR}/doc/man/spell-marker.1.md
#    PANDOC_DIRECTIVES
#        -t man
#    PRODUCT_DIRECTORY
#        doc/man
#)
197
198
199


# experimental binaries
damien's avatar
damien committed
200
#add_executable(test-json sandbox/test-json.cc)
201
                                
damien's avatar
damien committed
202
203

INSTALL(TARGETS spell-pedigree spell-marker spell-qtl DESTINATION bin)
204
205
206
207
208
209
210
211
212
#INSTALL(FILES
#        ${CMAKE_CURRENT_BINARY_DIR}/doc/man/spell-pedigree.1
#        ${CMAKE_CURRENT_BINARY_DIR}/doc/man/spell-marker.1
#        ${CMAKE_CURRENT_BINARY_DIR}/doc/man/spell-qtl.1
#        DESTINATION share/man/man1)

INSTALL(FILES ${CMAKE_SOURCE_DIR}/examples/read-POP.R
        DESTINATION share/spell-qtl/examples)

213
214
215
INSTALL(FILES ${CMAKE_BINARY_DIR}/doc/user_manual.pdf
        DESTINATION share/doc/spell-qtl)

216
INSTALL(FILES
damien's avatar
damien committed
217
218
219
220
221
222
        ${CMAKE_SOURCE_DIR}/examples/three_parents_F2/example1_F2C.gen
        ${CMAKE_SOURCE_DIR}/examples/three_parents_F2/example1_F2C.phen
        ${CMAKE_SOURCE_DIR}/examples/three_parents_F2/example1_F2.gen
        ${CMAKE_SOURCE_DIR}/examples/three_parents_F2/example1_F2.phen
        ${CMAKE_SOURCE_DIR}/examples/three_parents_F2/example1.map
        ${CMAKE_SOURCE_DIR}/examples/three_parents_F2/example1.ped
223
224
225
        ${CMAKE_SOURCE_DIR}/examples/three_parents_F2/README
        DESTINATION share/spell-qtl/examples/three_parents_F2)

226
INSTALL(FILES
damien's avatar
damien committed
227
228
229
230
231
232
233
234
        ${CMAKE_SOURCE_DIR}/examples/F3-outbred/F3-outbred_A.gen
        ${CMAKE_SOURCE_DIR}/examples/F3-outbred/F3-outbred_B.gen
        ${CMAKE_SOURCE_DIR}/examples/F3-outbred/F3-outbred_C.gen
        ${CMAKE_SOURCE_DIR}/examples/F3-outbred/F3-outbred_D.gen
        ${CMAKE_SOURCE_DIR}/examples/F3-outbred/F3-outbred_F3.gen
        ${CMAKE_SOURCE_DIR}/examples/F3-outbred/F3-outbred_F3.phen
        ${CMAKE_SOURCE_DIR}/examples/F3-outbred/F3-outbred.map
        ${CMAKE_SOURCE_DIR}/examples/F3-outbred/F3-outbred.ped
235
236
        ${CMAKE_SOURCE_DIR}/examples/F3-outbred/README
        DESTINATION share/spell-qtl/examples/F3-outbred)
237

damien's avatar
damien committed
238
239
240
241
242
243
244
245
246
247
248
249
250

INCLUDE(InstallRequiredSystemLibraries)

SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Software suite for the QTL analysis of modern datasets")
SET(CPACK_PACKAGE_VENDOR "Damien Leroux <damien.leroux@inra.fr>")
#SET(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/ReadMe.txt")
SET(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/COPYING")
SET(CPACK_PACKAGE_VERSION_MAJOR ${VERSION_MAJOR})
SET(CPACK_PACKAGE_VERSION_MINOR ${VERSION_MINOR})
SET(CPACK_PACKAGE_VERSION_PATCH ${VERSION_PATCH})
SET(CPACK_GENERATOR "DEB;STGZ")
SET(CPACK_DEBIAN_PACKAGE_MAINTAINER "Damien Leroux <damien.leroux@inra.fr>")

251
INCLUDE(CPack)