forked from MarcvdSluys/libSUFR
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
108 lines (84 loc) · 3.83 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
## CMakeFile for libSUFR
## AF, 2010-12-07
##
## Copyright 2010-2013 AstroFloyd - astrofloyd.org
##
## This file is part of the libSUFR package,
## see: http://libsufr.sf.net/
##
## This 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 software 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 code. If not, see
## <http://www.gnu.org/licenses/>.
##
##
## To compile, from the directory that contains this file, do:
## $ mkdir build; cd build
## $ cmake ..
## $ make install
cmake_minimum_required( VERSION 2.8 FATAL_ERROR )
# Set build type. Do this *before* we set the project name:
if( NOT CMAKE_BUILD_TYPE )
set( CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING
"Choose the type of build, options are: None Debug Release RelWithDebInfo Profile."
FORCE )
endif( NOT CMAKE_BUILD_TYPE )
set( CMAKE_CONFIGURATION_TYPES "${CMAKE_BUILD_TYPE}" CACHE INTERNAL "internal" )
# Project name and language:
project( libSUFR Fortran )
# Use CPack for packaging:
#include( CPack )
#set( CPACK_INSTALL_PREFIX_PATH ${CMAKE_INSTALL_PREFIX_PATH} )
# Increase verbosity for debugging:
option( CMAKE_VERBOSE_MAKEFILE "Verbose makefile" on )
# Search in the CMake/ directory for CMake modules:
list( APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/CMake )
# Various compile/optimisation options that we may want to enable:
include( SetCompileOptions )
# Place the products in their directories:
get_filename_component( Fortran_COMPILER_NAME ${CMAKE_Fortran_COMPILER} NAME )
if( COMPILER_SPECIFIC_LIBS )
set( MODULE_DIRECTORY "${CMAKE_SOURCE_DIR}/usr/include/libSUFR/${Fortran_COMPILER_NAME}" )
else( COMPILER_SPECIFIC_LIBS )
set( MODULE_DIRECTORY "${CMAKE_SOURCE_DIR}/usr/include/libSUFR" )
endif( COMPILER_SPECIFIC_LIBS )
set( LIBRARY_OUTPUT_PATH "${CMAKE_SOURCE_DIR}/usr/lib${LIB_SUFFIX}" )
# Set source files:
include( FileList )
# Set FORTRAN compiler flags:
include( CompilerFlags_Fortran )
# Code-version generator:
# This implies that the file libSUFR_version* is removed by 'make clean'!
if( CREATE_VERSION )
add_custom_command(
OUTPUT ${CMAKE_SOURCE_DIR}/src/libSUFR_version.f90
COMMAND cd $(CMAKE_SOURCE_DIR)
COMMAND . ${CMAKE_SOURCE_DIR}/code_version.sh ${CMAKE_SOURCE_DIR} src/libSUFR_version.f90 ${Fortran_COMPILER_NAME} ${OPT_FLAGS}
)
endif( CREATE_VERSION )
# Create libraries:
if( CREATE_SHAREDLIB )
add_library( "libSUFR_shared" SHARED ${SRC_FILES} )
if( COMPILER_SPECIFIC_LIBS )
set_target_properties( libSUFR_shared PROPERTIES OUTPUT_NAME "SUFR_${Fortran_COMPILER_NAME}" )
else( COMPILER_SPECIFIC_LIBS )
set_target_properties( libSUFR_shared PROPERTIES OUTPUT_NAME "SUFR" )
endif( COMPILER_SPECIFIC_LIBS )
set_target_properties( libSUFR_shared PROPERTIES Fortran_MODULE_DIRECTORY ${MODULE_DIRECTORY} )
endif( CREATE_SHAREDLIB )
if( CREATE_STATICLIB )
add_library( "libSUFR_static" STATIC ${SRC_FILES} )
if( COMPILER_SPECIFIC_LIBS )
set_target_properties( libSUFR_static PROPERTIES OUTPUT_NAME "SUFR_${Fortran_COMPILER_NAME}" )
else( COMPILER_SPECIFIC_LIBS )
set_target_properties( libSUFR_static PROPERTIES OUTPUT_NAME "SUFR" )
endif( COMPILER_SPECIFIC_LIBS )
set_target_properties( libSUFR_static PROPERTIES Fortran_MODULE_DIRECTORY ${MODULE_DIRECTORY} )
endif( CREATE_STATICLIB )
# Install to destination:
# use DIRECTORY rather than TARGETS to allow include/<fortrancompiler>/
install( DIRECTORY usr/ DESTINATION ${CMAKE_INSTALL_PREFIX} )