1 | |
---|
2 | # We want to run coverage analysis of |
---|
3 | # the files compiled here.. |
---|
4 | include(buildtypeCoverage) |
---|
5 | |
---|
6 | # list of source files |
---|
7 | file(GLOB src_files |
---|
8 | mad_*.c |
---|
9 | *.f90 |
---|
10 | *.F90 |
---|
11 | *.cpp) |
---|
12 | file(GLOB main_file mad_main.c) |
---|
13 | if(WIN32 OR CYGWIN) |
---|
14 | file(GLOB gxx_remove gxx11c.c gxx11.f90) |
---|
15 | else() |
---|
16 | file(GLOB gxx_remove gxx11psc.c gxx11ps.f90) |
---|
17 | endif() |
---|
18 | |
---|
19 | # Some source files which should not be included: |
---|
20 | file(GLOB sdds_remove matchsdds.c) |
---|
21 | |
---|
22 | if(NOT MADX_FORCE_32) |
---|
23 | # find laplas and blas |
---|
24 | find_package(LAPACK) |
---|
25 | endif() |
---|
26 | |
---|
27 | if(LAPACK_FOUND AND BLAS_FOUND) |
---|
28 | message(STATUS "LAPACK uses ${LAPACK_LIBRARIES}") |
---|
29 | file(GLOB lapack_remove matchlib.f90 matchlib2.f90) |
---|
30 | else() |
---|
31 | # Note, this only APPENDS -O0 to the compile flags, same as Makefile currently does. |
---|
32 | set_source_files_properties(matchlib2.f90 PROPERTIES COMPILE_FLAGS "-O0") |
---|
33 | endif() |
---|
34 | |
---|
35 | # remove source files according to NTPSA option... |
---|
36 | if(MADX_NTPSA) |
---|
37 | message(STATUS "NTPSA turned on") |
---|
38 | file(GLOB ntpsa_remove c_dabnew.f90) |
---|
39 | else() |
---|
40 | file(GLOB ntpsa_remove c_dabnew_berz.f90 c_tpsa_interface.f90 tpsa.cpp) |
---|
41 | endif() |
---|
42 | |
---|
43 | set(remove_list ${gxx_remove} ${sdds_remove} ${ntpsa_remove} ${lapack_remove}) |
---|
44 | list(REMOVE_ITEM src_files ${remove_list}) |
---|
45 | |
---|
46 | # header files... |
---|
47 | file(GLOB headerfiles *.h) |
---|
48 | |
---|
49 | # adding library: |
---|
50 | add_library(madx ${src_files}) |
---|
51 | |
---|
52 | target_link_libraries(madx ptc) |
---|
53 | |
---|
54 | |
---|
55 | # not sure if this is needed... |
---|
56 | set_target_properties(madx PROPERTIES LINKER_LANGUAGE Fortran) |
---|
57 | |
---|
58 | # set library version: |
---|
59 | set_target_properties(madx PROPERTIES VERSION ${MADX_VERSION} SOVERSION 1) |
---|
60 | |
---|
61 | # adding an executable: |
---|
62 | if(MADX_BUNDLE) |
---|
63 | add_executable(madxbin MACOSX_BUNDLE ${main_file}) |
---|
64 | else() |
---|
65 | add_executable(madxbin ${main_file}) |
---|
66 | endif() |
---|
67 | set_target_properties(madxbin PROPERTIES LINKER_LANGUAGE Fortran VERSION ${MADX_VERSION}) |
---|
68 | |
---|
69 | # we want to add _dev to the binary in case this is a dev version for the automatic packaging... |
---|
70 | set_target_properties(madxbin PROPERTIES OUTPUT_NAME "madx${BINARY_POSTFIX}") |
---|
71 | |
---|
72 | # we need to link executable to our own library: |
---|
73 | target_link_libraries(madxbin madx) |
---|
74 | |
---|
75 | # I turn off search for libraries in case you are on Linux, |
---|
76 | # to make sure we make use of the lib/lib64 folders |
---|
77 | if(NOT CMAKE_SYSTEM_NAME STREQUAL "Linux") |
---|
78 | #necessary to search for X11 for OSX instead of directly including it |
---|
79 | find_package(X11) |
---|
80 | if(X11_FOUND) |
---|
81 | include_directories(${X11_INCLUDE_DIR}) |
---|
82 | target_link_libraries(madx ${X11_X11_LIB}) |
---|
83 | endif() |
---|
84 | else() |
---|
85 | target_link_libraries(madx X11) |
---|
86 | endif() |
---|
87 | |
---|
88 | if(LAPACK_FOUND AND BLAS_FOUND) |
---|
89 | target_link_libraries(madx ${LAPACK_LIBRARIES}) |
---|
90 | endif() |
---|
91 | |
---|
92 | # Online libraries: |
---|
93 | if(MADX_ONLINE) |
---|
94 | target_link_libraries(madx ${SDDS_LIBRARIES}) |
---|
95 | endif() |
---|
96 | if(NOT WIN32) |
---|
97 | target_link_libraries(madx z) |
---|
98 | endif() |
---|
99 | |
---|
100 | find_package(Threads) |
---|
101 | find_package(STDCPP) |
---|
102 | target_link_libraries(madx ${CMAKE_THREAD_LIBS_INIT} ${STDCPP_LIBS}) |
---|
103 | |
---|
104 | # Defining specific stuff for packaging: |
---|
105 | # Should be called after sources are defined, |
---|
106 | # before targets are defined. |
---|
107 | include(setupPackaging) |
---|
108 | |
---|
109 | # |
---|
110 | # we call a subscript that sets up installation stuff: |
---|
111 | # |
---|
112 | # Should be called after targets are defined |
---|
113 | # |
---|
114 | include(setupInstallation) |
---|