diff options
author | Antenore Gatta <antenore@simbiosi.org> | 2018-08-30 23:30:56 +0300 |
---|---|---|
committer | Antenore Gatta <antenore@simbiosi.org> | 2018-08-30 23:30:56 +0300 |
commit | d52707c0ff5730b99008b9760ab70f0293fa79f3 (patch) | |
tree | 3eee285979c99ef233e1c34ae79aa7798599cd35 /CMakeLists.txt | |
parent | 853ba6754e54066a51268fd0e7040d0929ef6950 (diff) |
Printing builds flags with remmina --full-version command option.
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r-- | CMakeLists.txt | 133 |
1 files changed, 128 insertions, 5 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 89f5a2864..e827d5e8a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -39,10 +39,11 @@ set(CMAKE_COLOR_MAKEFILE ON) project(Remmina C) +include(CheckCCompilerFlag) include(CheckIncludeFiles) include(CheckLibraryExists) +include(CheckSymbolExists) include(FindPkgConfig) -include(CheckCCompilerFlag) include(GNUInstallDirs) set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/) @@ -59,14 +60,125 @@ if(NOT BUILD_SHARED_LIBS) endif() if(CMAKE_COMPILER_IS_GNUCC) + if(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64" OR CMAKE_SYSTEM_PROCESSOR MATCHES "i686") + CHECK_SYMBOL_EXISTS(__x86_64__ "" IS_X86_64) + if(IS_X86_64) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC") + else() + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=i686") + endif() + else() + if(CMAKE_POSITION_INDEPENDENT_CODE) + if(${CMAKE_VERSION} VERSION_LESS 2.8.9) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC") + endif() + endif() + endif() + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall") - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC") + if(WITH_SSE2) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse2") endif() - check_c_compiler_flag(-Wno-unused-function Wno-unused-function) - if(Wno-unused-function) - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused-function") + + if(CMAKE_BUILD_TYPE STREQUAL "Debug") + add_definitions(-DDEBUG) + CHECK_C_COMPILER_FLAG (-Wunused-result Wunused-result) + if(Wunused-result) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wunused-result") + endif() + CHECK_C_COMPILER_FLAG (-Wunused-but-set-variable Wunused-but-set-variable) + if(Wunused-but-set-variable) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wunused-but-set-variable") + endif() + CHECK_C_COMPILER_FLAG(-Wdeprecated-declarations Wdeprecated-declarations) + if(Wdeprecated-declarations) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wdeprecated-declarations") + endif() + + CHECK_C_COMPILER_FLAG (-Wimplicit-function-declaration Wimplicit-function-declaration) + if(Wimplicit-function-declaration) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wimplicit-function-declaration") + endif() + if (NOT OPENBSD) + CHECK_C_COMPILER_FLAG (-Wredundant-decls Wredundant-decls) + if(Wredundant-decls) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wredundant-decls") + endif() + endif() + endif() + + if(CMAKE_BUILD_TYPE STREQUAL "Release") + add_definitions(-DNDEBUG) + CHECK_C_COMPILER_FLAG (-Wno-unused-result Wno-unused-result) + if(Wno-unused-result) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused-result") + endif() + CHECK_C_COMPILER_FLAG (-Wno-unused-but-set-variable Wno-unused-but-set-variable) + if(Wno-unused-but-set-variable) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused-but-set-variable") + endif() + CHECK_C_COMPILER_FLAG(-Wno-deprecated-declarations Wno-deprecated-declarations) + if(Wno-deprecated-declarations) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-deprecated-declarations") + endif() + + CHECK_C_COMPILER_FLAG (-Wimplicit-function-declaration Wimplicit-function-declaration) + if(Wimplicit-function-declaration) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wimplicit-function-declaration") + endif() + if (NOT OPENBSD) + CHECK_C_COMPILER_FLAG (-Wredundant-decls Wredundant-decls) + if(Wredundant-decls) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wredundant-decls") + endif() + endif() + else() + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g") + endif() + +endif() + +if((TARGET_ARCH MATCHES "x86|x64") AND (NOT DEFINED WITH_SSE2)) + option(WITH_SSE2 "Enable SSE2 optimization." ON) +else() + option(WITH_SSE2 "Enable SSE2 optimization." OFF) +endif() + +if(TARGET_ARCH MATCHES "ARM") + if (NOT DEFINED WITH_NEON) + option(WITH_NEON "Enable NEON optimization." ON) + else() + option(WITH_NEON "Enable NEON optimization." OFF) + endif() +else() + if(NOT APPLE) + option(WITH_IPP "Use Intel Performance Primitives." OFF) + endif() +endif() + + +if(${CMAKE_C_COMPILER_ID} STREQUAL "Clang") + if(CMAKE_BUILD_TYPE STREQUAL "Release") + add_definitions(-DNDEBUG) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused-parameter") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused-macros -Wno-padded") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-c11-extensions -Wno-gnu") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused-command-line-argument") + CHECK_C_COMPILER_FLAG(-Wno-deprecated-declarations Wno-deprecated-declarations) + if(Wno-deprecated-declarations) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-deprecated-declarations") + endif() + else() + add_definitions(-DDEBUG) + #set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wunused-parameter") + #set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wunused-macros -Wpadded") + #set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wc11-extensions -Wgnu") + #set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wunused-command-line-argument") + CHECK_C_COMPILER_FLAG(-Wdeprecated-declarations Wdeprecated-declarations) + if(Wdeprecated-declarations) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wdeprecated-declarations") + endif() endif() endif() @@ -252,3 +364,14 @@ endif() configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.in ${CMAKE_CURRENT_SOURCE_DIR}/config.h) + +set(REMMINA_BUILD_CONFIG_LIST "") +GET_CMAKE_PROPERTY(res VARIABLES) +FOREACH(var ${res}) + IF (var MATCHES "^WITH_*|^HAVE_*") + LIST(APPEND REMMINA_BUILD_CONFIG_LIST "${var}=${${var}}") + ENDIF() +ENDFOREACH() +string(REPLACE ";" " " REMMINA_BUILD_CONFIG "${REMMINA_BUILD_CONFIG_LIST}") +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/buildflags.h.in + ${CMAKE_CURRENT_SOURCE_DIR}/buildflags.h) |