CMakeLists.txt 9.66 KB
Newer Older
jcl's avatar
jcl committed
1
# ============================================================================
LAMBERT Jean-charles's avatar
LAMBERT Jean-charles committed
2
# Copyright Jean-Charles LAMBERT - 2010-2016
jclamber's avatar
updates  
jclamber committed
3
# e-mail:   Jean-Charles.Lambert@lam.fr                                      
4 5
# address:  Dynamique des galaxies
#           Centre de donneeS Astrophysique de Marseille (CeSAM)
jcl's avatar
jcl committed
6 7 8 9
#           Laboratoire d'Astrophysique de Marseille                          
#           Pole de l'Etoile, site de Chateau-Gombert                         
#           38, rue Frederic Joliot-Curie                                     
#           13388 Marseille cedex 13 France                                   
jclamber's avatar
updates  
jclamber committed
10
#           CNRS U.M.R 7326                                                   
jcl's avatar
jcl committed
11
# ============================================================================
jclamber's avatar
updates  
jclamber committed
12
# CMakeListst.txt file 
jcl's avatar
jcl committed
13
# ============================================================================
14

jcl's avatar
jcl committed
15
cmake_minimum_required(VERSION 2.6)
16

17 18 19
if (POLICY CMP0054)
  cmake_policy(SET CMP0054 NEW)
endif()
20

jcl's avatar
jcl committed
21 22 23
# project name
project (uns_projects)

24 25
# extra path for NEMO
SET(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH} )
jcl's avatar
jcl committed
26 27
MESSAGE( STATUS "CMAKE_MODULE_PATH=" ${CMAKE_MODULE_PATH} )

28 29 30
# load setup flags
include(SetupFlags)

31 32 33 34 35 36 37 38 39 40
# use ccache if any
find_program(CCACHE_FOUND ccache)
if(CCACHE_FOUND)
  set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache)
  set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache)
endif(CCACHE_FOUND)

# Cpack Generator detection
include(DetectCpackGenerator)

41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
# contains the full path to the top level directory of your build tree
MESSAGE( STATUS "PROJECT_BINARY_DIR: " ${PROJECT_BINARY_DIR} )

# contains the full path to the root of your project source directory,
# i.e. to the nearest directory where CMakeLists.txt contains the PROJECT() command
MESSAGE( STATUS "PROJECT_SOURCE_DIR: " ${PROJECT_SOURCE_DIR} )

MESSAGE( STATUS "CMAKE_BUILD_TYPE =" ${CMAKE_BUILD_TYPE} )
MESSAGE( STATUS "CMAKE_CXX_FLAGS  =" ${CMAKE_CXX_FLAGS} )
MESSAGE( STATUS "LIBRARY TYPE     =" ${LIBTYPE} )

MESSAGE( STATUS "core OPT  =" ${OPT} )
MESSAGE( STATUS "OSX detected =" ${OSX} )
MESSAGE( STATUS "BUILD_TYPE =" ${RELEASE} )

56 57 58
MESSAGE( STATUS "EXTRA_INCLUDES =" ${EXTRA_INCLUDES} )
MESSAGE( STATUS "EXTRA_LINK_DIRS =" ${EXTRA_LINK_DIRS} )

jcl's avatar
jcl committed
59 60
# require NEMO
FIND_PACKAGE(NEMO REQUIRED)
61 62
# require UNSIO
FIND_PACKAGE(UNSIO REQUIRED)
jcl's avatar
jcl committed
63
# Sqlite3
64
#FIND_PACKAGE(SQLITE3)
65 66
# Boost (deprecated)
FIND_PACKAGE(BOOST)
jcl's avatar
jcl committed
67 68 69 70 71 72 73 74 75 76 77 78 79

#FIND_PACKAGE(NEMO REQUIRED)
MESSAGE( STATUS "NEMOLIB : " ${NEMOLIB} )

# contains the full path to the top level directory of your build tree 
MESSAGE( STATUS "PROJECT_BINARY_DIR: " ${PROJECT_BINARY_DIR} )
#MESSAGE ( STATUS "Boost_LIBRARY_DIRS : " ${Boost_LIBRARY_DIRS}) 
# contains the full path to the root of your project source directory,
# i.e. to the nearest directory where CMakeLists.txt contains the PROJECT() command 
MESSAGE( STATUS "PROJECT_SOURCE_DIR: " ${PROJECT_SOURCE_DIR} )


# Find all the sources for the utils LIB
80 81

if ( NEMO_INSTALLED )
jclamber's avatar
jclamber committed
82
   FILE(GLOB LIBUTILS ${PROJECT_SOURCE_DIR}/lib/utils/*.cc ${PROJECT_SOURCE_DIR}/lib/utils/*.c ${PROJECT_SOURCE_DIR}/lib/utils/nemodep/*.cc)
83
else ()
jclamber's avatar
jclamber committed
84
   FILE(GLOB LIBUTILS ${PROJECT_SOURCE_DIR}/lib/utils/*.cc ${PROJECT_SOURCE_DIR}/lib/utils/*.c)
85
endif ()
jcl's avatar
jcl committed
86 87 88 89 90 91
# create the library "JCLutils"
add_library (JCLutils SHARED ${LIBUTILS})
if(OSX)
set_target_properties(JCLutils PROPERTIES LINK_FLAGS "-undefined suppress -flat_namespace")
endif(OSX)
# Find all the sources for the projects LIB
92 93 94 95 96
if ( NEMO_INSTALLED )
   FILE(GLOB LIBPROJECTS ${PROJECT_SOURCE_DIR}/lib/projects/*.cc ${PROJECT_SOURCE_DIR}/lib/projects/nemodep/*.cc)
else ()
   FILE(GLOB LIBPROJECTS ${PROJECT_SOURCE_DIR}/lib/projects/*.cc)
endif ()
jcl's avatar
jcl committed
97 98 99 100 101 102
# create the library "JCLutils"
add_library (JCLprojects SHARED ${LIBPROJECTS})
if(OSX)
set_target_properties(JCLprojects PROPERTIES LINK_FLAGS "-undefined suppress -flat_namespace")
endif(OSX)
# Destination path for the lib
103
SET(LIBRARY_OUTPUT_PATH lib)
jcl's avatar
jcl committed
104 105 106


# compilation options
107 108
#add_definitions(${OPT} -DNO_CUDA -DfalcON_NEMO -DfalcON_SINGLE  -funroll-loops -Wall ${DNOBOOST})
add_definitions(${OPT} -DNO_CUDA -DfalcON_NEMO -DfalcON_SINGLE  -Wall ${DNOBOOST})
109 110 111
SET(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} ${WARNCPP} )
SET(CMAKE_C_FLAGS ${CMAKE_C_FLAGS} ${WARNC} )
SET(CMAKE_Fortran_FLAGS ${CMAKE_Fortran_FLAGS} ${WARNF})
jcl's avatar
jcl committed
112

113 114 115 116
# remove -DNDEBUG in RElease mode to keep activated assert calls
STRING(REPLACE "-DNDEBUG" ""  CMAKE_CXX_FLAGS_RELEASE ${CMAKE_CXX_FLAGS_RELEASE})
message (STATUS "CMAKE_CXX_FLAGS_RELEASE = " ${CMAKE_CXX_FLAGS_RELEASE}  )

jcl's avatar
jcl committed
117
# Executbale output path
118
set(EXECUTABLE_OUTPUT_PATH bin)
jcl's avatar
jcl committed
119 120 121
MESSAGE( STATUS "EXECUTABLE_OUTPUT_PATH: " ${EXECUTABLE_OUTPUT_PATH} )

# Make sure the compiler can find include files from our Hello library.
122 123 124
include_directories (${PROJECT_SOURCE_DIR}/src )
include_directories (${PROJECT_SOURCE_DIR}/lib/utils ${PROJECT_SOURCE_DIR}/lib/utils/nemodep )
include_directories (${PROJECT_SOURCE_DIR}/lib/projects ${PROJECT_SOURCE_DIR}/lib/projects/nemodep)
LAMBERT Jean-charles's avatar
LAMBERT Jean-charles committed
125
include_directories (/usr/include/CCfits /usr/include/cfitsio /opt/usr/include /opt/usr/include/CCfits)
126
include_directories (${EXTRA_INCLUDES})
127 128 129
if ( FALCON_INSTALLED )
  include_directories (${DEHNEN}/falcON/utils/inc ${DEHNEN}/falcON/inc)
endif()
130
include_directories (${UNSIOPATH}/lib ${UNSIOPATH}/include ${UNSIOPATH}/include/nemo ${UNSIOPATH}/include/uns $ENV{NEMO}/inc $ENV{NEMO}/inc/uns $ENV{NEMO}/lib)
131
include_directories (/usr/include/malloc)
jcl's avatar
jcl committed
132 133

# Make sure the linker can find the Hello library once it is built.
134
link_directories ( ${UNSIOPATH}/${LIB_SUFFIX} ${UNSIOPATH}/lib ${UNSIOPATH}/lib64 ${DEHNEN}/falcON/lib ${DEHNEN}/utils/lib $ENV{PGPLOT_DIR}  ${G2C_DIR} ${PROJECT_BINARY_DIR}/lib /usr/lib64 /usr/X11/lib ${FC_GFORT_PATH} ${FC_G77_PATH} ${EXTRA_LINK_DIRS})
jcl's avatar
jcl committed
135

jclamber's avatar
jclamber committed
136 137 138 139 140
# ----------------------------------------------------------
# Install SETUP
# ----------------------------------------------------------
mark_as_advanced(CMAKE_INSTALL_PREFIX)

141
if ( "XX${CMAKE_INSTALL_PREFIX}" STREQUAL "XX$ENV{NEMO}" )
142 143 144 145
  SET(PREFIX_LIB lib)
else()
  SET(PREFIX_LIB ${LIB_SUFFIX})
endif()
146 147

if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) 
148 149
  set (CMAKE_INSTALL_PREFIX ${UNSIOPATH})
endif()
150
MESSAGE( STATUS "--------> CMAKE_INSTALL_PREFIX =" ${CMAKE_INSTALL_PREFIX} )
jclamber's avatar
jclamber committed
151

jclamber's avatar
jclamber committed
152 153 154 155
if (OSX)
  MESSAGE(STATUS "\nAfter running \"make install\", do not forget to set your environment variable DYLD_LIBRARY_PATH using command:\n\n export DYLD_LIBRARY_PATH=${CMAKE_INSTALL_PREFIX}/lib\n")
endif(OSX)

jclamber's avatar
jclamber committed
156 157 158 159 160 161
# use, i.e. don't skip the full RPATH for the build tree
SET(CMAKE_SKIP_BUILD_RPATH  FALSE)
# when building, don't use the install RPATH already
# (but later on when installing)
SET(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)

162
SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${PREFIX_LIB}")
jclamber's avatar
jclamber committed
163 164 165 166 167 168

# add the automatically determined parts of the RPATH
# which point to directories outside the build tree to the install RPATH
SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)

# the RPATH to be used when installing, but only if it's not a system directory
169
LIST(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX}/${PREFIX_LIB}" isSystemDir)
jclamber's avatar
jclamber committed
170
IF("${isSystemDir}" STREQUAL "-1")
171
   SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${PREFIX_LIB}")
jclamber's avatar
jclamber committed
172
ENDIF("${isSystemDir}" STREQUAL "-1")
jcl's avatar
jcl committed
173 174 175 176 177

# ----------------------------------------------------------
# Make sure the compiler can find include files from our Hello library.
#include_directories (${UNS_SOURCE_DIR}/src $ENV{NEMOINC} ${NEMOLIB})

178
# Find all exes sources files
jcl's avatar
jcl committed
179

180 181 182 183 184
if ( NEMO_INSTALLED )
   FILE(GLOB execpp_sources ${PROJECT_SOURCE_DIR}/src/*.cc ${PROJECT_SOURCE_DIR}/src/nemodep/*.cc)
else ()
   FILE(GLOB execpp_sources ${PROJECT_SOURCE_DIR}/src/*.cc)
endif ()
jcl's avatar
jcl committed
185
# build cpp executables according to the source
186 187 188 189 190 191
if (NEMO_INSTALLED)
  set (LINK_NEMO "-lnemo")
else ()
    set (LINK_NEMO "")
endif()

jcl's avatar
jcl committed
192 193 194 195 196 197
FOREACH(exe_cpp ${execpp_sources})

  get_filename_component(exe ${exe_cpp} NAME_WE)
  MESSAGE( STATUS "New executable ==> " ${exe})
  add_executable (${exe} ${exe_cpp})

198 199
 #
  if ( NEMO_INSTALLED )
200 201 202
         # with fits
         # target_link_libraries (${exe} JCLprojects JCLutils cpgplot pgplot.a ${FC_GFORT_LIB} ${FC_G77_LIB}  CCfits cfitsio X11 nemo unsio WDutils falcON gomp ${LIBBOOST} pthread dl)
         # without fits
203
	 target_link_libraries (${exe} JCLprojects JCLutils cpgplot pgplot.a ${FC_GFORT_LIB} ${FC_G77_LIB} X11 ${LINK_NEMO} unsio WDutils falcON gomp ${LIBBOOST} pthread dl)
204
  else ()
205 206 207
    # with fits
	  # target_link_libraries (${exe} JCLprojects JCLutils ${FC_GFORT_LIB} ${FC_G77_LIB} CCfits cfitsio nemo unsio gomp ${LIBBOOST} dl)
    # without fits
208
    target_link_libraries (${exe} JCLprojects JCLutils ${FC_GFORT_LIB} ${FC_G77_LIB} ${LINK_NEMO} unsio gomp ${LIBBOOST} dl)
209
  endif ()
jclamber's avatar
jclamber committed
210
  INSTALL(TARGETS ${exe} RUNTIME  DESTINATION bin)
jcl's avatar
jcl committed
211 212 213 214 215 216

ENDFOREACH(exe_cpp ${execpp_sources})

# ----------------------------------------------------------
# install target                                            

jclamber's avatar
jclamber committed
217

jcl's avatar
jcl committed
218 219 220 221 222 223 224 225 226 227

IF   (OSX) # Mac OSX
  SET(SOEXT "dylib")
ELSE (OSX) # Linux
  SET(SOEXT "so")
ENDIF(OSX)
# 
# install bin targets
FOREACH(exe_cpp ${execpp_sources})
  get_filename_component(exe ${exe_cpp} NAME_WE)
jclamber's avatar
jclamber committed
228
  #INSTALL(PROGRAMS  ${PROJECT_BINARY_DIR}/bin/${exe}     DESTINATION bin)
jcl's avatar
jcl committed
229
ENDFOREACH(exe_cpp ${execpp_sources})
230 231 232

INSTALL(FILES  ${PROJECT_BINARY_DIR}/lib/libJCLutils.${SOEXT} DESTINATION ${PREFIX_LIB})
INSTALL(FILES  ${PROJECT_BINARY_DIR}/lib/libJCLprojects.${SOEXT} DESTINATION ${PREFIX_LIB})
jclamber's avatar
jclamber committed
233 234
INSTALL(FILES  ${PROJECT_SOURCE_DIR}/lib/utils/nemodep/cfalcon.h DESTINATION inc/uns)
INSTALL(FILES  ${PROJECT_SOURCE_DIR}/lib/utils/csnaptools.h DESTINATION inc/uns)
jclamber's avatar
jclamber committed
235
INSTALL(FILES  ${PROJECT_SOURCE_DIR}/lib/projects/nemodep/crectify.h DESTINATION inc/uns)
jclamber's avatar
jclamber committed
236
INSTALL(FILES  ${PROJECT_SOURCE_DIR}/lib/utils/ctimer.h DESTINATION inc/uns)
237 238 239 240 241 242

# Manuals
FILE(GLOB manuals  ${PROJECT_SOURCE_DIR}/man/*.1)
FOREACH(install_man ${manuals})
  INSTALL(FILES  ${install_man}  DESTINATION man/man1)
ENDFOREACH()
jcl's avatar
jcl committed
243
#