Debian Codegraph @

cmake/custom_static_library.cmake

raw
1 # Downloaded from
2 # https://github.com/PCMSolver/pcmsolver/blob/release/1.Y/cmake/custom/static_library.cmake
3 # * suppressed STATIC_LIBRARY_ONLY
4 # * moved option up
5 # * corrected CXX block matches statements from C --> CXX compiler
6
7 #.rst:
8 #
9 # Enables creation of static library.
10 # If the shared library is created, make it as static as possible.
11 #
12 # Variables modified (provided the corresponding language is enabled)::
13 #
14 # CMAKE_Fortran_FLAGS
15 # CMAKE_C_FLAGS
16 # CMAKE_CXX_FLAGS
17 #
18 # autocmake.cfg configuration::
19 #
20 # docopt: --static Create only the static library [default: False].
21 # define: '-DSTATIC_LIBRARY_ONLY=%s' % arguments['--static']
22
23 if(ENABLE_GENERIC)
24 if(DEFINED CMAKE_Fortran_COMPILER_ID)
25 if(CMAKE_Fortran_COMPILER_ID MATCHES GNU)
26 set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -static-libgfortran")
27 endif()
28 if(CMAKE_Fortran_COMPILER_ID MATCHES Intel)
29 set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -static-libgcc -static-intel")
30 endif()
31 endif()
32
33 if(DEFINED CMAKE_C_COMPILER_ID)
34 if(CMAKE_C_COMPILER_ID MATCHES GNU)
35 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -static-libgcc -fpic")
36 endif()
37 if(CMAKE_C_COMPILER_ID MATCHES Intel)
38 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -static-libgcc -static-intel -wd10237")
39 endif()
40 if(CMAKE_C_COMPILER_ID MATCHES Clang)
41 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fpic")
42 endif()
43 endif()
44
45 if(DEFINED CMAKE_CXX_COMPILER_ID)
46 if(CMAKE_CXX_COMPILER_ID MATCHES GNU)
47 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static-libstdc++ -static-libgcc")
48 endif()
49 if(CMAKE_CXX_COMPILER_ID MATCHES Intel)
50 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wl,--as-needed -static-libstdc++ -static-libgcc -static-intel -wd10237")
51 endif()
52 if(CMAKE_CXX_COMPILER_ID MATCHES Clang)
53 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static-libstdc++")
54 endif()
55 endif()
56 endif()