From 8470b6ea267430d479f16a15f0521618b23cbe12 Mon Sep 17 00:00:00 2001 From: akallabeth Date: Thu, 3 Aug 2023 09:45:43 +0200 Subject: [PATCH] [cmake] set default build type set with CACHE STRING FORCE to properly be picked up by configuration tools --- CMakeLists.txt | 9 +++++---- client/Mac/CMakeLists.txt | 26 +++++++++++++++----------- client/SDL/CMakeLists.txt | 4 ++++ client/Sample/CMakeLists.txt | 4 ++++ client/X11/CMakeLists.txt | 4 ++++ client/iOS/CMakeLists.txt | 4 ++++ rdtk/CMakeLists.txt | 4 ++-- uwac/CMakeLists.txt | 4 ++-- winpr/CMakeLists.txt | 2 +- 9 files changed, 41 insertions(+), 20 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7808d47d4..89a0f22b7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -26,6 +26,11 @@ set(CMAKE_C_STANDARD 11) set(CMAKE_C_STANDARD_REQUIRED ON) set(CMAKE_C_EXTENSIONS ON) +# Default to release build type +if(NOT CMAKE_BUILD_TYPE) + set(CMAKE_BUILD_TYPE "Release" CACHE STRING "project default" FORCE) +endif() + add_custom_target(fuzzers COMMENT "Build fuzzers") @@ -196,10 +201,6 @@ endif(CMAKE_CROSSCOMPILING) # Turn on solution folders (2.8.4+) set_property(GLOBAL PROPERTY USE_FOLDERS ON) -# Default to release build type -if(NOT CMAKE_BUILD_TYPE) - set(CMAKE_BUILD_TYPE "Release") -endif() set(LIB_DEFAULT ON) if (IOS) diff --git a/client/Mac/CMakeLists.txt b/client/Mac/CMakeLists.txt index c489db9d1..f56af3513 100644 --- a/client/Mac/CMakeLists.txt +++ b/client/Mac/CMakeLists.txt @@ -5,6 +5,10 @@ project(MacFreeRDP-library) cmake_policy(SET CMP0026 OLD) cmake_policy(SET CMP0045 OLD) +if(NOT CMAKE_BUILD_TYPE) + set(CMAKE_BUILD_TYPE "Release" CACHE STRING "project default" FORCE) +endif() + set(MODULE_NAME "MacFreeRDP-library") set(MODULE_OUTPUT_NAME "MacFreeRDP") set(MODULE_PREFIX "FREERDP_CLIENT_MAC_LIBRARY") @@ -58,7 +62,7 @@ set(${MODULE_PREFIX}_HEADERS set(${MODULE_PREFIX}_RESOURCES "en.lproj/InfoPlist.strings") -# Include XIB file in Xcode resources. +# Include XIB file in Xcode resources. if("${CMAKE_GENERATOR}" MATCHES "Xcode") message(STATUS "Adding Xcode XIB resources for ${MODULE_NAME}") set(${MODULE_PREFIX}_RESOURCES ${${MODULE_PREFIX}_RESOURCES} ${${MODULE_PREFIX}_XIBS}) @@ -75,12 +79,12 @@ set_target_properties(${MODULE_NAME} PROPERTIES OUTPUT_NAME "${MODULE_OUTPUT_NAM # configures the framework to always be looked for in the application bundle in the Frameworks sub-folder. set_target_properties(${MODULE_NAME} PROPERTIES XCODE_ATTRIBUTE_INSTALL_PATH @executable_path/../Frameworks/) - + set_target_properties(${MODULE_NAME} PROPERTIES - RUNTIME_OUTPUT_DIRECTORY_DEBUG ${EXECUTABLE_OUTPUT_PATH} + RUNTIME_OUTPUT_DIRECTORY_DEBUG ${EXECUTABLE_OUTPUT_PATH} RUNTIME_OUTPUT_DIRECTORY_RELEASE ${EXECUTABLE_OUTPUT_PATH}) -set_target_properties(${MODULE_NAME} PROPERTIES +set_target_properties(${MODULE_NAME} PROPERTIES FRAMEWORK TRUE MACOSX_FRAMEWORK_IDENTIFIER com.awakecoding.${MODULE_NAME} FRAMEWORK_VERSION ${FREERDP_VERSION} @@ -119,12 +123,12 @@ else() endif() if (${BUILD_SHARED_LIBS}) - # Add a post-build event to copy the dependent libraries in the framework bundle + # Add a post-build event to copy the dependent libraries in the framework bundle # Call install_name_tool to reassign the library install name foreach(LIB ${DEPENDENCIES}) # message("adding post-build dependency: ${LIB}") - add_custom_command(TARGET ${MODULE_NAME} POST_BUILD - COMMAND "${CMAKE_COMMAND}" -E copy + add_custom_command(TARGET ${MODULE_NAME} POST_BUILD + COMMAND "${CMAKE_COMMAND}" -E copy "$" "${CMAKE_CURRENT_BINARY_DIR}/${safe_configuration}/${MODULE_OUTPUT_NAME}.framework/Contents/$" COMMENT "Copying ${LIB} to output directory" @@ -159,7 +163,7 @@ endif() # skip generation of this project find_program(IBTOOL ibtool HINTS "/usr/bin" "${OSX_DEVELOPER_ROOT}/usr/bin") if (${IBTOOL} STREQUAL "IBTOOL-NOTFOUND") - message(SEND_ERROR "ibtool can not be found and is needed to compile the .xib files. It should have been installed with + message(SEND_ERROR "ibtool can not be found and is needed to compile the .xib files. It should have been installed with the Apple developer tools. The default system paths were searched in addition to ${OSX_DEVELOPER_ROOT}/usr/bin") endif() @@ -170,9 +174,9 @@ endif() # Compile the .xib files using the 'ibtool' program with the destination being the app package foreach(xib ${${MODULE_PREFIX}_XIBS}) get_filename_component(XIB_WE ${xib} NAME_WE) - - add_custom_command (TARGET ${MODULE_NAME} POST_BUILD - COMMAND ${IBTOOL} --errors --warnings --notices --output-format human-readable-text + + add_custom_command (TARGET ${MODULE_NAME} POST_BUILD + COMMAND ${IBTOOL} --errors --warnings --notices --output-format human-readable-text --compile ${CMAKE_CURRENT_BINARY_DIR}/${safe_configuration}/${MODULE_OUTPUT_NAME}.framework/Versions/${MACOSX_BUNDLE_SHORT_VERSION_STRING}/Resources/${XIB_WE}.nib ${CMAKE_CURRENT_SOURCE_DIR}/${xib} COMMENT "Compiling ${xib}") endforeach() diff --git a/client/SDL/CMakeLists.txt b/client/SDL/CMakeLists.txt index 9f9971499..e6a80da16 100644 --- a/client/SDL/CMakeLists.txt +++ b/client/SDL/CMakeLists.txt @@ -39,6 +39,10 @@ option(WITH_DEBUG_SDL_EVENTS "[dangerous, not for release builds!] Debug SDL eve option(WITH_DEBUG_SDL_KBD_EVENTS "[dangerous, not for release builds!] Debug SDL keyboard events" OFF) option(WITH_WIN_CONSOLE "Build ${PROJECT_NAME} with console support" ON) +if(NOT CMAKE_BUILD_TYPE) + set(CMAKE_BUILD_TYPE "Release" CACHE STRING "project default" FORCE) +endif() + # Configure MSVC Runtime if(MSVC) include(MSVCRuntime) diff --git a/client/Sample/CMakeLists.txt b/client/Sample/CMakeLists.txt index f7d8a3be7..900fe89d1 100644 --- a/client/Sample/CMakeLists.txt +++ b/client/Sample/CMakeLists.txt @@ -27,6 +27,10 @@ option(CMAKE_VERBOSE_MAKEFILE "verbose CMake makefile" ON) option(CMAKE_POSITION_INDEPENDENT_CODE "build with position independent code (-fPIC or -fPIE)" ON) list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/) +if(NOT CMAKE_BUILD_TYPE) + set(CMAKE_BUILD_TYPE "Release" CACHE STRING "project default" FORCE) +endif() + include(ConfigureFreeRDP) include(GNUInstallDirsWrapper) diff --git a/client/X11/CMakeLists.txt b/client/X11/CMakeLists.txt index 903262608..b779ad9f4 100644 --- a/client/X11/CMakeLists.txt +++ b/client/X11/CMakeLists.txt @@ -28,6 +28,10 @@ option(CMAKE_VERBOSE_MAKEFILE "verbose CMake makefile" ON) option(CMAKE_POSITION_INDEPENDENT_CODE "build with position independent code (-fPIC or -fPIE)" ON) list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/) +if(NOT CMAKE_BUILD_TYPE) + set(CMAKE_BUILD_TYPE "Release" CACHE STRING "project default" FORCE) +endif() + include(ConfigureFreeRDP) include(GNUInstallDirsWrapper) diff --git a/client/iOS/CMakeLists.txt b/client/iOS/CMakeLists.txt index 4970cee08..1f86c2a08 100644 --- a/client/iOS/CMakeLists.txt +++ b/client/iOS/CMakeLists.txt @@ -16,6 +16,10 @@ # limitations under the License. project(iFreeRDP) +if(NOT CMAKE_BUILD_TYPE) + set(CMAKE_BUILD_TYPE "Release" CACHE STRING "project default" FORCE) +endif() + set(MODULE_NAME "iFreeRDP") set(MODULE_PREFIX "IFREERDP_CLIENT") set(APP_TYPE MACOSX_BUNDLE) diff --git a/rdtk/CMakeLists.txt b/rdtk/CMakeLists.txt index 5271c346c..ce5207e37 100644 --- a/rdtk/CMakeLists.txt +++ b/rdtk/CMakeLists.txt @@ -44,13 +44,13 @@ if (NOT FREERDP_UNIFIED_BUILD) set(WINPR_VERSION_MAJOR 3) option(BUILD_SHARED_LIBS "Build shared libraries" ON) - option(EXPORT_ALL_SYMBOLS "Export all symbols form library" OFF) + option(EXPORT_ALL_SYMBOLS "Export all symbols form library" OFF) option(BUILD_TESTING "Build library unit tests" ON) option(WITH_LIBRARY_VERSIONING "Use library version triplet" ON) # Default to release build type if(NOT CMAKE_BUILD_TYPE) - set(CMAKE_BUILD_TYPE "Release") + set(CMAKE_BUILD_TYPE "Release" CACHE STRING "project default" FORCE) endif() if(CMAKE_COMPILER_IS_GNUCC) diff --git a/uwac/CMakeLists.txt b/uwac/CMakeLists.txt index 0ab79e8e4..42e7028b6 100644 --- a/uwac/CMakeLists.txt +++ b/uwac/CMakeLists.txt @@ -65,8 +65,8 @@ include(SetFreeRDPCMakeInstallDir) include(CMakePackageConfigHelpers) include(GNUInstallDirsWrapper) -if (NOT CMAKE_BUILD_TYPE) - set(CMAKE_BUILD_TYPE Release) +if(NOT CMAKE_BUILD_TYPE) + set(CMAKE_BUILD_TYPE "Release" CACHE STRING "project default" FORCE) endif() if (NOT IOS) diff --git a/winpr/CMakeLists.txt b/winpr/CMakeLists.txt index 3bdef90ba..cdd843ef0 100644 --- a/winpr/CMakeLists.txt +++ b/winpr/CMakeLists.txt @@ -293,7 +293,7 @@ endif() # Default to release build type if(NOT CMAKE_BUILD_TYPE) - set(CMAKE_BUILD_TYPE "Release") + set(CMAKE_BUILD_TYPE "Release" CACHE STRING "project default" FORCE) endif() if(BUILD_SHARED_LIBS)