cmake: fix cpu flags autodiscovery and terminal for raspberry

- we set cpu flags for CXX and C
- raspberry "only" has lxterminal not xterm
This commit is contained in:
Davide Gerhard 2019-08-27 17:43:27 +02:00
parent a1c16a67ef
commit df22522126
No known key found for this signature in database
GPG Key ID: 7CBEFA144857DC97
3 changed files with 130 additions and 105 deletions

View File

@ -34,7 +34,15 @@ set(COPYRIGHT "Copyright (c) 2019 John Langner, WB2OSZ. All rights reserved.")
add_definitions("-DCOPYRIGHT=\"${COPYRIGHT}\"")
set(IDENTIFIER "com.${COMPANY}.${APPLICATION_NAME}")
add_definitions("-DIDENTIFIER=\"${IDENTIFIER}\"")
set(APPLICATION_DESKTOP_EXEC "xterm -e ${CMAKE_PROJECT_NAME}")
# raspberry as only lxterminal not xterm
if(NOT WIN32)
find_program(BINARY_TERMINAL_BIN lxterminal)
if(BINARY_TERMINAL_BIN)
set(APPLICATION_DESKTOP_EXEC "${BINARY_TERMINAL_BIN} -e ${CMAKE_PROJECT_NAME}")
else()
set(APPLICATION_DESKTOP_EXEC "xterm -e ${CMAKE_PROJECT_NAME}")
endif()
endif()
find_package(Git)
if(GIT_FOUND AND EXISTS "${CMAKE_SOURCE_DIR}/.git/")

View File

@ -53,12 +53,14 @@ if (${ARCHITECTURE} MATCHES "x86_64|x86" AND (FORCE_SSE OR FORCE_SSSE3 OR FORCE_
if (FORCE_SSE)
set(HAS_SSE ON CACHE BOOL "SSE SIMD enabled")
if(C_GCC OR C_CLANG)
set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse" )
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse" )
message(STATUS "Use SSE SIMD instructions")
add_definitions(-DUSE_SSE)
elseif(C_MSVC)
#set( CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /arch:SSE" )
#set( CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Oi /GL /Ot /Ox /arch:SSE" )
set( CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /arch:SSE" )
set( CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /arch:SSE" )
set( CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /Oi /GL /Ot /Ox" )
set( CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Oi /GL /Ot /Ox" )
set( CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /LTCG" )
message(STATUS "Use MSVC SSSE3 SIMD instructions")
@ -68,12 +70,14 @@ if (${ARCHITECTURE} MATCHES "x86_64|x86" AND (FORCE_SSE OR FORCE_SSSE3 OR FORCE_
elseif (FORCE_SSSE3)
set(HAS_SSSE3 ON CACHE BOOL "SSSE3 SIMD enabled")
if(C_GCC OR C_CLANG)
set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mssse3" )
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mssse3" )
message(STATUS "Use SSSE3 SIMD instructions")
add_definitions(-DUSE_SSSE3)
elseif(C_MSVC)
#set( CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /arch:SSSE3" )
#set( CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Oi /GL /Ot /Ox /arch:SSSE3" )
set( CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /arch:SSSE3" )
set( CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /arch:SSSE3" )
set( CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /Oi /GL /Ot /Ox" )
set( CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Oi /GL /Ot /Ox" )
set( CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /LTCG" )
message(STATUS "Use MSVC SSSE3 SIMD instructions")
@ -84,15 +88,16 @@ if (${ARCHITECTURE} MATCHES "x86_64|x86" AND (FORCE_SSE OR FORCE_SSSE3 OR FORCE_
set(HAS_SSSE3 ON CACHE BOOL "SSSE3 SIMD enabled")
set(HAS_SSE4_1 ON CACHE BOOL "Architecture has SSE 4.1 SIMD enabled")
if(C_GCC OR C_CLANG)
set( CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -msse4.1" )
set( CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -msse4.1" )
set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse4.1" )
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse4.1" )
message(STATUS "Use SSE 4.1 SIMD instructions")
add_definitions(-DUSE_SSSE3)
add_definitions(-DUSE_SSE4_1)
elseif(C_MSVC)
# seems that from MSVC 2015 comiler doesn't support those flags
#set( CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /arch:SSE4_1" )
#set( CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Oi /GL /Ot /Ox /arch:SSE4_1" )
set( CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /arch:SSE4_1" )
set( CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /arch:SSE4_1" )
set( CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /Oi /GL /Ot /Ox" )
set( CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Oi /GL /Ot /Ox" )
set( CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /LTCG" )
message(STATUS "Use SSE 4.1 SIMD instructions")
@ -102,7 +107,7 @@ if (${ARCHITECTURE} MATCHES "x86_64|x86" AND (FORCE_SSE OR FORCE_SSSE3 OR FORCE_
endif()
endif()
else ()
if (${ARCHITECTURE} MATCHES "x86_64|x86")
if (${ARCHITECTURE} MATCHES "x86_64|x86")
if(C_MSVC)
try_run(RUN_SSE2 COMPILE_SSE2 "${CMAKE_BINARY_DIR}/tmp" "${TEST_DIR}/test_x86_sse2.cxx" COMPILE_DEFINITIONS /O0)
else()
@ -112,10 +117,13 @@ if (${ARCHITECTURE} MATCHES "x86_64|x86")
set(HAS_SSE2 ON CACHE BOOL "Architecture has SSSE2 SIMD enabled")
message(STATUS "Use SSE2 SIMD instructions")
if(C_GCC OR C_CLANG)
set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse2" )
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse2" )
add_definitions(-DUSE_SSE2)
elseif(C_MSVC)
set( CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /arch:SSE2" )
set( CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /arch:SSE2" )
set( CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /Oi /GL /Ot /Ox /arch:SSE2" )
set( CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Oi /GL /Ot /Ox /arch:SSE2" )
set( CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /LTCG" )
add_definitions (/D "_CRT_SECURE_NO_WARNINGS")
@ -133,12 +141,13 @@ if (${ARCHITECTURE} MATCHES "x86_64|x86")
set(HAS_SSSE3 ON CACHE BOOL "Architecture has SSSE3 SIMD enabled")
message(STATUS "Use SSSE3 SIMD instructions")
if(C_GCC OR C_CLANG)
set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mssse3" )
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mssse3" )
add_definitions(-DUSE_SSSE3)
elseif(C_MSVC)
# seems not present on MSVC 2017
#set( CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /arch:SSSE3" )
#set( CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Oi /GL /Ot /Ox /arch:SSSE3" )
set( CMAKE_C_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Oi /GL /Ot /Ox" )
set( CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Oi /GL /Ot /Ox" )
set( CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /LTCG" )
add_definitions (/D "_CRT_SECURE_NO_WARNINGS")
@ -156,13 +165,14 @@ if (${ARCHITECTURE} MATCHES "x86_64|x86")
set(HAS_SSE4_1 ON CACHE BOOL "Architecture has SSE 4.1 SIMD enabled")
message(STATUS "Use SSE 4.1 SIMD instructions")
if(C_GCC OR C_CLANG)
set( CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -msse4.1" )
set( CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -msse4.1" )
set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse4.1" )
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse4.1" )
add_definitions(-DUSE_SSE4_1)
elseif(C_MSVC)
# seems not present on MSVC 2017
#set( CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /arch:SSE4_1" )
#set( CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Oi /GL /Ot /Ox /arch:SSE4_1" )
set( CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /Oi /GL /Ot /Ox" )
set( CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Oi /GL /Ot /Ox" )
set( CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /LTCG" )
add_definitions (/D "_CRT_SECURE_NO_WARNINGS")
@ -180,14 +190,15 @@ if (${ARCHITECTURE} MATCHES "x86_64|x86")
set(HAS_SSE4_2 ON CACHE BOOL "Architecture has SSE 4.2 SIMD enabled")
message(STATUS "Use SSE 4.2 SIMD instructions")
if(C_GCC OR C_CLANG)
set( CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -msse4.2" )
set( CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -msse4.2" )
set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse4.2" )
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse4.2" )
add_definitions(-DUSE_SSE4_2)
elseif(C_MSVC)
# seems not present on MSVC 2017
#set( CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /arch:SSE4_2" )
#set( CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Oi /GL /Ot /Ox /arch:SSE4_2" )
set( CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Oi /GL /Ot /Ox" )
set( CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /Oi /GL /Ot /Ox" )
set( CMAKE_CXX_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /Oi /GL /Ot /Ox" )
set( CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /LTCG" )
add_definitions (/D "_CRT_SECURE_NO_WARNINGS")
add_definitions(-DUSE_SSE4_2)
@ -204,11 +215,13 @@ if (${ARCHITECTURE} MATCHES "x86_64|x86")
set(HAS_AVX ON CACHE BOOL "Architecture has AVX SIMD enabled")
message(STATUS "Use AVX SIMD instructions")
if(C_GCC OR C_CLANG)
set( CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -mavx" )
set( CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -mavx" )
set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mavx" )
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mavx" )
add_definitions(-DUSE_AVX)
elseif(C_MSVC)
set( CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /arch:AVX" )
set( CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /arch:AVX" )
set( CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /Oi /GL /Ot /Ox /arch:AVX" )
set( CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Oi /GL /Ot /Ox /arch:AVX" )
set( CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /LTCG" )
add_definitions (/D "_CRT_SECURE_NO_WARNINGS")
@ -226,11 +239,13 @@ if (${ARCHITECTURE} MATCHES "x86_64|x86")
set(HAS_AVX2 ON CACHE BOOL "Architecture has AVX2 SIMD enabled")
message(STATUS "Use AVX2 SIMD instructions")
if(C_GCC OR C_CLANG)
set( CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -mavx2" )
set( CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -mavx2" )
set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mavx2" )
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mavx2" )
add_definitions(-DUSE_AVX2)
elseif(C_MSVC)
set( CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /arch:AVX2" )
set( CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /arch:AVX2" )
set( CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /Oi /GL /Ot /Ox /arch:AVX2" )
set( CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Oi /GL /Ot /Ox /arch:AVX2" )
set( CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /LTCG" )
add_definitions (/D "_CRT_SECURE_NO_WARNINGS")
@ -248,11 +263,13 @@ if (${ARCHITECTURE} MATCHES "x86_64|x86")
set(HAS_AVX512 ON CACHE BOOL "Architecture has AVX512 SIMD enabled")
message(STATUS "Use AVX512 SIMD instructions")
if(C_GCC OR C_CLANG)
set( CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -mavx512f" )
set( CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -mavx512f" )
set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mavx512f" )
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mavx512f" )
add_definitions(-DUSE_AVX512)
elseif(C_MSVC)
set( CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /arch:AVX512" )
set( CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /arch:AVX512" )
set( CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /Oi /GL /Ot /Ox /arch:AVX512" )
set( CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Oi /GL /Ot /Ox /arch:AVX512" )
set( CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /LTCG" )
add_definitions (/D "_CRT_SECURE_NO_WARNINGS")
@ -271,8 +288,8 @@ elseif(ARCHITECTURE_ARM)
set(HAS_NEON ON CACHE BOOL "Architecture has NEON SIMD enabled")
message(STATUS "Use NEON SIMD instructions")
if(C_GCC OR C_CLANG)
set( CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -mfpu=neon" )
set( CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -mfpu=neon" )
set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mfpu=neon" )
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mfpu=neon" )
add_definitions(-DUSE_NEON)
endif()
else()

View File

@ -42,7 +42,7 @@ add_custom_target(install-conf-conf
COMMAND ${CMAKE_COMMAND} -E copy "${CUSTOM_CONF_DIR}/sdr.conf" ~
)
if(LINUX)
if(NOT WIN32)
add_custom_target(install-conf)
add_dependencies(install-conf install-conf-conf install-conf-scripts install-conf-telemetry)
endif()