1 | ### |
---|
2 | # |
---|
3 | # This file sets compiler specific flags |
---|
4 | # and runs some special stuff needed for specific |
---|
5 | # compiler selections |
---|
6 | # |
---|
7 | ### |
---|
8 | |
---|
9 | set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH}" "${CMAKE_CURRENT_LIST_DIR}/compilers") |
---|
10 | |
---|
11 | # These two compilers can be mixed at will... |
---|
12 | include(setupGNU) |
---|
13 | include(setupIntel) |
---|
14 | |
---|
15 | # Only Fortran.. |
---|
16 | if(CMAKE_Fortran_COMPILER MATCHES "lf95") |
---|
17 | message( WARNING " This compiler is not supported for Mad-X") |
---|
18 | include(setupLahey) |
---|
19 | elseif(CMAKE_Fortran_COMPILER MATCHES "nagfor") |
---|
20 | message( WARNING " This compiler is not supported for Mad-X") |
---|
21 | include(setupNAGFOR) |
---|
22 | elseif(CMAKE_Fortran_COMPILER MATCHES "g77") |
---|
23 | message( WARNING " This compiler is not supported for Mad-X") |
---|
24 | message( "--- ifort is recommended fortran compiler ---") |
---|
25 | set(CMAKE_Fortran_FLAGS_RELEASE " -funroll-loops -fno-f2c -O3 ") |
---|
26 | set(CMAKE_Fortran_FLAGS_DEBUG " -fno-f2c -O0 -g ") |
---|
27 | if ( MADX_STATIC ) |
---|
28 | set(CMAKE_Fortran_LINK_FLAGS "${CMAKE_Fortran_LINK_FLAGS} -static ") |
---|
29 | endif () |
---|
30 | elseif(CMAKE_Fortran_COMPILER MATCHES "g95") |
---|
31 | message( WARNING " This compiler is not supported for Mad-X") |
---|
32 | set(CMAKE_Fortran_FLAGS_RELEASE " -funroll-loops -fno-second-underscore -fshort-circuit -O2 ") |
---|
33 | set(CMAKE_Fortran_FLAGS_DEBUG " -fno-second-underscore -O3 -g -Wall -pedantic -ggdb3") |
---|
34 | if ( MADX_STATIC ) |
---|
35 | set(CMAKE_Fortran_LINK_FLAGS "${CMAKE_Fortran_LINK_FLAGS} -static ") |
---|
36 | endif () |
---|
37 | elseif(CMAKE_Fortran_COMPILER_ID MATCHES "PathScale") |
---|
38 | message( WARNING " This compiler is not supported for Mad-X") |
---|
39 | include(setupPathScale) |
---|
40 | endif() |
---|
41 | #end fortran compiler stuff... |
---|
42 | |
---|
43 | |
---|
44 | # General compile flags: |
---|
45 | set(CMAKE_Fortran_FLAGS_RELWITHDEBINFO "-g ${CMAKE_Fortran_FLAGS_RELEASE}") |
---|
46 | set(CMAKE_C_FLAGS_DEBUG " ${CMAKE_C_FLAGS_DEBUG} -Wall -pedantic") |
---|
47 | if(NOT (WIN32 AND CMAKE_C_COMPILER_ID STREQUAL "Intel")) |
---|
48 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -funroll-loops -std=c99") |
---|
49 | endif() |
---|
50 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -funroll-loops") #needed for c++ linking |
---|
51 | set(CMAKE_CXX_FLAGS_DEBUG " ${CMAKE_CXX_FLAGS_DEBUG} -Wall") |
---|
52 | if(MADX_DEBUG) |
---|
53 | add_definitions(-D_DEBUG -DDEBUG_ALL) |
---|
54 | endif() |
---|
55 | |
---|
56 | add_definitions(-D_FULL -D_VERSION=${MADX_VERSION} -D_VERSION_DATE=${VERSION_DATE} -D_VERSION_OSTYPE=${CMAKE_SYSTEM_NAME}) |
---|
57 | |
---|
58 | # C stuff: |
---|
59 | # -- not needed for gnu/intel -- |
---|
60 | if(CMAKE_C_COMPILER_ID MATCHES "GNU" AND NOT CMAKE_Fortran_COMPILER_ID MATCHES "GNU") |
---|
61 | execute_process(COMMAND ${C_COMPILER_NAME} -print-search-dirs |
---|
62 | OUTPUT_VARIABLE gccsearchdirs) |
---|
63 | string(REGEX REPLACE ".*libraries: =(.*)\n" "\\1" gcclibs "${gccsearchdirs}") |
---|
64 | # need to do this many times because lf95 segfaults on lists with : |
---|
65 | string(REPLACE "/:/" "/ -L/" gcclibs "${gcclibs}") |
---|
66 | # adding these to the linking process which is handled by a non-gnu fortran compiler in your case |
---|
67 | link_directories(${gcclibs}) |
---|
68 | endif() |
---|
69 | # -- end of not needed for gnu/intel -- |
---|
70 | # end C stuff |
---|
71 | |
---|
72 | if(MADX_ONLINE) |
---|
73 | message(STATUS "Online model turned on") |
---|
74 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_ONLINE ") |
---|
75 | set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -D_ONLINE ") |
---|
76 | endif() |
---|