CMakeLists.txt
changeset 9152 c884e40dca9e
parent 9151 1d2df388fcc6
child 9160 fc46e75f6b72
child 9165 7b0d5388abc4
equal deleted inserted replaced
9151:1d2df388fcc6 9152:c884e40dca9e
    92 else (CMAKE_BUILD_TYPE)
    92 else (CMAKE_BUILD_TYPE)
    93     set (CMAKE_BUILD_TYPE ${default_build_type} CACHE STRING "Build type (Debug/Release)" FORCE)
    93     set (CMAKE_BUILD_TYPE ${default_build_type} CACHE STRING "Build type (Debug/Release)" FORCE)
    94 endif (CMAKE_BUILD_TYPE)
    94 endif (CMAKE_BUILD_TYPE)
    95 
    95 
    96 
    96 
       
    97 #perform safe check that enable/disable compilation features
       
    98 include(${CMAKE_MODULE_PATH}/compilerchecks.cmake)
       
    99 
    97 #set default flags values for all projects (unless MINIMAL_FLAGS is true)
   100 #set default flags values for all projects (unless MINIMAL_FLAGS is true)
    98 if(NOT ${MINIMAL_FLAGS})
   101 if(NOT ${MINIMAL_FLAGS})
    99     set(CMAKE_C_FLAGS "-pipe ${CMAKE_C_FLAGS}")
   102     set(CMAKE_C_FLAGS "-pipe ${CMAKE_C_FLAGS}")
   100     set(CMAKE_C_FLAGS_RELEASE "-w -Os -fomit-frame-pointer ${CMAKE_C_FLAGS_RELEASE}")
   103     set(CMAKE_C_FLAGS_RELEASE "-w -Os -fomit-frame-pointer ${CMAKE_C_FLAGS_RELEASE}")
   101     set(CMAKE_C_FLAGS_DEBUG "-Wall -O0 -g -DDEBUG ${CMAKE_C_FLAGS_DEBUG}")
   104     set(CMAKE_C_FLAGS_DEBUG "-Wall -O0 -g -DDEBUG ${CMAKE_C_FLAGS_DEBUG}")
   107     set(CMAKE_C_FLAGS_RELEASE "")
   110     set(CMAKE_C_FLAGS_RELEASE "")
   108     set(CMAKE_C_FLAGS_DEBUG "-Wall -DDEBUG")
   111     set(CMAKE_C_FLAGS_DEBUG "-Wall -DDEBUG")
   109     set(CMAKE_CXX_FLAGS_RELEASE "")
   112     set(CMAKE_CXX_FLAGS_RELEASE "")
   110     set(CMAKE_CXX_FLAGS_DEBUG "-Wall -DDEBUG")
   113     set(CMAKE_CXX_FLAGS_DEBUG "-Wall -DDEBUG")
   111 endif()
   114 endif()
   112 
       
   113 
       
   114 #TESTING TIME
       
   115 include(CheckCCompilerFlag)
       
   116 
       
   117 #check for noexecstack on ELF, should be set on Gentoo and similar
       
   118 set(CMAKE_REQUIRED_FLAGS "-Wl,-z -Wl,noexecstack")
       
   119 check_c_compiler_flag("" HAVE_NOEXECSTACK) #empty because we are testing a linker flag
       
   120 if(HAVE_NOEXECSTACK)
       
   121     list(APPEND pascal_flags "-k-z" "-knoexecstack")
       
   122     set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_REQUIRED_FLAGS}")
       
   123 endif()
       
   124 unset(CMAKE_REQUIRED_FLAGS)
       
   125 
       
   126 #check for ASLR and DEP security features on Windows
       
   127 #both supported in binutils >= 2.20, available since Vista and XP SP2 respectively
       
   128 set(CMAKE_REQUIRED_FLAGS "-Wl,--nxcompat -Wl,--dynamicbase")
       
   129 check_c_compiler_flag("" HAVE_WINASLRDEP) #empty because we are testing a linker flag
       
   130 if(HAVE_WINASLRDEP)
       
   131     list(APPEND pascal_flags "-k--nxcompat" "-k--dynamicbase")
       
   132     set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_REQUIRED_FLAGS}")
       
   133 endif()
       
   134 unset(CMAKE_REQUIRED_FLAGS)
       
   135 
   115 
   136 #parse additional parameters
   116 #parse additional parameters
   137 if(FPFLAGS OR GHFLAGS)
   117 if(FPFLAGS OR GHFLAGS)
   138     if(CMAKE_VERSION VERSION_GREATER "2.6")
   118     if(CMAKE_VERSION VERSION_GREATER "2.6")
   139         separate_arguments(fpflags_parsed UNIX_COMMAND ${FPFLAGS})
   119         separate_arguments(fpflags_parsed UNIX_COMMAND ${FPFLAGS})