diff options
Diffstat (limited to 'BuildFlags.cmake')
-rw-r--r-- | BuildFlags.cmake | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/BuildFlags.cmake b/BuildFlags.cmake new file mode 100644 index 0000000..92b9c72 --- /dev/null +++ b/BuildFlags.cmake @@ -0,0 +1,31 @@ +# Set default build flags + +IF("${CMAKE_BUILD_TYPE}" STREQUAL "") + SET(CMAKE_BUILD_TYPE "Release") +ENDIF() + +SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -g -Werror -Wno-deprecated-declarations") +SET(CMAKE_C_FLAGS_DEBUG "-O0") +SET(CMAKE_C_FLAGS_RELEASE "-O2") + +SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--as-needed") +SET(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -Wl,--as-needed") +SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--as-needed") + +MESSAGE(STATUS "Build type: ${CMAKE_BUILD_TYPE}") +MESSAGE(STATUS "Compile flags: ${CMAKE_C_FLAGS}") +MESSAGE(STATUS "Exe linker flags: ${CMAKE_EXE_LINKER_FLAGS}") +MESSAGE(STATUS "Module linker flags: ${CMAKE_MODULE_LINKER_FLAGS}") +MESSAGE(STATUS "Shared linker flags: ${CMAKE_SHARED_LINKER_FLAGS}") + +IF("${CMAKE_BUILD_TYPE}" STREQUAL "Debug") + ADD_DEFINITIONS("-DDEBUG") +ENDIF() + +MACRO(get_version _file _ver _ver_maj) + FILE(STRINGS ${_file} __log LIMIT_COUNT 1 REGEX "(.*)") + STRING(REGEX REPLACE ".*\\(\([0-9]+:\)*\([0-9a-zA-Z.]*\).*\\).*" "\\2" __ver ${__log}) + STRING(REGEX REPLACE "^\([0-9]+\)\\..*" "\\1" __ver_maj ${__ver}) + SET(${_ver} ${__ver}) + SET(${_ver_maj} ${__ver_maj}) +ENDMACRO(get_version) |