summaryrefslogtreecommitdiffstats
path: root/UserMacros.cmake
blob: bf609e5bed23a8c9fe6629e3c52b84ed27560b67 (plain)
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
########################################################
#  Include file for user options
########################################################

#-----------------------------------------------------------------------------
# Option to Build with Static CRT libraries on Windows
#-------------------------------------------------------------------------------
MACRO (TARGET_STATIC_CRT_FLAGS)
  IF (MSVC AND NOT BUILD_SHARED_LIBS)
    FOREACH (flag_var
        CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE
        CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO
        CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE
        CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO)
      IF (${flag_var} MATCHES "/MD")
        STRING (REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
      ENDIF (${flag_var} MATCHES "/MD")
    ENDFOREACH (flag_var)
    FOREACH (flag_var
        CMAKE_Fortran_FLAGS CMAKE_Fortran_FLAGS_DEBUG CMAKE_Fortran_FLAGS_RELEASE
        CMAKE_Fortran_FLAGS_MINSIZEREL CMAKE_Fortran_FLAGS_RELWITHDEBINFO)
      IF (${flag_var} MATCHES "/libs:dll")
        STRING (REGEX REPLACE "/libs:dll" "/libs:static" ${flag_var} "${${flag_var}}")
      ENDIF (${flag_var} MATCHES "/libs:dll")
    ENDFOREACH (flag_var)
    SET (WIN_COMPILE_FLAGS "/MT")
    SET (WIN_LINK_FLAGS "/NODEFAULTLIB:MSVCRT")
  ENDIF (MSVC AND NOT BUILD_SHARED_LIBS)
ENDMACRO (TARGET_STATIC_CRT_FLAGS)

#-----------------------------------------------------------------------------
OPTION (BUILD_STATIC_CRT_LIBS "Build With Static CRT Libraries" OFF)
IF (BUILD_STATIC_CRT_LIBS)
  TARGET_STATIC_CRT_FLAGS ()
ENDIF (BUILD_STATIC_CRT_LIBS)