1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-15 21:01:45 -05:00

Merge pull request #694 from kasper93/win32

CMake: Add an option to hide console on Windows
This commit is contained in:
Edouard Griffiths 2020-11-08 09:49:53 +01:00 committed by GitHub
commit c5eb6a2eeb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 9 deletions

View File

@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.10.0) cmake_minimum_required(VERSION 3.13.0)
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL") set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL")
@ -25,6 +25,7 @@ option(SANITIZE_ADDRESS "Activate memory address sanitization" OFF)
option(RX_SAMPLE_24BIT "Internal 24 bit Rx DSP" ON) option(RX_SAMPLE_24BIT "Internal 24 bit Rx DSP" ON)
option(BUILD_SERVER "Build Server" ON) option(BUILD_SERVER "Build Server" ON)
option(BUILD_GUI "Build GUI" ON) option(BUILD_GUI "Build GUI" ON)
option(HIDE_CONSOLE "Hide console when running GUI on Windows" ON)
option(BUNDLE "Enable distribution bundle" OFF) option(BUNDLE "Enable distribution bundle" OFF)
option(FORCE_SSSE3 "Compile with SSSE3 instruction only" OFF) option(FORCE_SSSE3 "Compile with SSSE3 instruction only" OFF)
option(FORCE_SSE41 "Compile with SSE4.1 instruction only" OFF) option(FORCE_SSE41 "Compile with SSE4.1 instruction only" OFF)
@ -287,11 +288,21 @@ endif()
if (SANITIZE_ADDRESS) if (SANITIZE_ADDRESS)
message(STATUS "Activate address sanitization") message(STATUS "Activate address sanitization")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address") if(MSVC)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=address") set(ASAN_LIB_ARCH ${MSVC_CXX_ARCHITECTURE_ID})
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -fsanitize=address") string(TOLOWER ${ASAN_LIB_ARCH} ASAN_LIB_ARCH)
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fsanitize=address") if(ASAN_LIB_ARCH STREQUAL "x86")
set(CMAKE_STATIC_LINKER_FLAGS "${CMAKE_STATIC_LINKER_FLAGS} -fsanitize=address") set(ASAN_LIB_ARCH "i386")
elseif(ASAN_LIB_ARCH STREQUAL "x64")
set(ASAN_LIB_ARCH "x86_64")
endif()
add_compile_options(/fsanitize=address)
link_libraries(clang_rt.asan_dynamic-${ASAN_LIB_ARCH} clang_rt.asan_dynamic_runtime_thunk-${ASAN_LIB_ARCH})
add_link_options(/wholearchive:clang_rt.asan_dynamic_runtime_thunk-${ASAN_LIB_ARCH}.lib)
else()
add_compile_options(-fsanitize=address -fno-omit-frame-pointer -g)
add_link_options(-fsanitize=address)
endif()
endif() endif()
if (C_CLANG OR C_GCC) if (C_CLANG OR C_GCC)
@ -552,8 +563,9 @@ if (BUILD_GUI)
logging logging
) )
if (MSVC) if(WIN32)
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS} /SUBSYSTEM:WINDOWS /ENTRY:mainCRTStartup") set_target_properties(${CMAKE_PROJECT_NAME} PROPERTIES
WIN32_EXECUTABLE ${HIDE_CONSOLE})
endif() endif()
endif() endif()

View File

@ -481,6 +481,7 @@ if (LINUX)
PREFIX "${EXTERNAL_BUILD_LIBRARIES}/rtlsdr" PREFIX "${EXTERNAL_BUILD_LIBRARIES}/rtlsdr"
CMAKE_ARGS ${COMMON_CMAKE_ARGS} -DDETACH_KERNEL_DRIVER=ON -DINSTALL_UDEV_RULES=${RTLSDR_UDEV} CMAKE_ARGS ${COMMON_CMAKE_ARGS} -DDETACH_KERNEL_DRIVER=ON -DINSTALL_UDEV_RULES=${RTLSDR_UDEV}
BUILD_BYPRODUCTS "${LIBRTLSDR_LIBRARIES}" BUILD_BYPRODUCTS "${LIBRTLSDR_LIBRARIES}"
BUILD_COMMAND ${CMAKE_COMMAND} --build <BINARY_DIR> --config $<CONFIG> -- rtlsdr_shared
INSTALL_COMMAND "" INSTALL_COMMAND ""
TEST_COMMAND "" TEST_COMMAND ""
) )
@ -525,6 +526,7 @@ if (WIN32 OR APPLE)
-DTHREADS_PTHREADS_INCLUDE_DIR=${PTHREADS4W_INCLUDE_DIR} -DTHREADS_PTHREADS_INCLUDE_DIR=${PTHREADS4W_INCLUDE_DIR}
-DTHREADS_PTHREADS_WIN32_LIBRARY=${PTHREADS4W_LIBRARIES} -DTHREADS_PTHREADS_WIN32_LIBRARY=${PTHREADS4W_LIBRARIES}
BUILD_BYPRODUCTS "${LIBRTLSDR_LIBRARIES}" BUILD_BYPRODUCTS "${LIBRTLSDR_LIBRARIES}"
BUILD_COMMAND ${CMAKE_COMMAND} --build <BINARY_DIR> --config $<CONFIG> -- rtlsdr_shared
INSTALL_COMMAND "" INSTALL_COMMAND ""
TEST_COMMAND "" TEST_COMMAND ""
) )
@ -593,6 +595,7 @@ if (WIN32 OR APPLE)
-DENABLE_PYTHON3=OFF -DENABLE_PYTHON3=OFF
-DENABLE_TESTS=OFF -DENABLE_TESTS=OFF
BUILD_BYPRODUCTS "${SOAPYSDR_LIBRARY}" BUILD_BYPRODUCTS "${SOAPYSDR_LIBRARY}"
BUILD_COMMAND ${CMAKE_COMMAND} --build <BINARY_DIR> --config $<CONFIG> -- SoapySDR
INSTALL_COMMAND "" INSTALL_COMMAND ""
TEST_COMMAND "" TEST_COMMAND ""
) )