From 7887be861e8d9d90f6f7fb429ab9e98b6fb46d5e Mon Sep 17 00:00:00 2001 From: Tobias Taschner Date: Mon, 5 Feb 2018 21:42:31 +0100 Subject: [PATCH 1/4] CMake: Set default configuration types Only use Debug and Release as default configuration types --- CMakeLists.txt | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 42be0430e7..a067b00356 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,6 +9,14 @@ cmake_minimum_required(VERSION 2.8.12) +if(NOT CMAKE_CONFIGURATION_TYPES) + get_property(HAVE_MULTI_CONFIG_GENERATOR GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) + # Set default configuration types for multi-config generators + if(HAVE_MULTI_CONFIG_GENERATOR) + set(CMAKE_CONFIGURATION_TYPES "Debug;Release") + endif() +endif() + if(APPLE AND NOT CMAKE_OSX_DEPLOYMENT_TARGET) # If no deployment target has been set default to the minimum supported # OS X version (this has to be set before the first project() call) From 9fd43699317a35936b8d9a275ecf710e6ac12a49 Mon Sep 17 00:00:00 2001 From: Tobias Taschner Date: Mon, 5 Feb 2018 21:49:40 +0100 Subject: [PATCH 2/4] CMake: Update cmake/README.md Update minor stuff and mention upmake --- build/cmake/README.md | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/build/cmake/README.md b/build/cmake/README.md index eed238ef2d..708b78a434 100644 --- a/build/cmake/README.md +++ b/build/cmake/README.md @@ -7,7 +7,7 @@ documentation. CMake files organization ======================== -All CMake files are located in $(wx)/build/cmake additionally there is a +All CMake files are located in _$(wx)/build/cmake_ additionally there is a _CMakeLists.txt_ in the root directory. Files @@ -19,15 +19,16 @@ Files * Generates config files used to find wxWidgets by other build systems * Creates wx-config * files.cmake - * List of source files generated by _update_files.py_ from _$(wx)/build/files_ - * This file should **never** be edited manually + * List of source files generated by _$(wx)build/upmake_ from _$(wx)build/files_ + * This file should usually **never** be edited manually + * However if a new group of files is added it needs to be edited manually * functions.cmake * contains various wxWidgets specific functions and macros used throughout the CMake files * Every function should contain a short description of it's parameters as a comment before the function/macro * install.cmake - * Handles defintions for the ´install` and `uninstall` target + * Handles defintions for the `install` and `uninstall` target * init.cmake * Intializes various variables used during the build process and for generation of setup.h and configuration files @@ -49,8 +50,6 @@ Files * Define toolkit specific options and detection to this file * uninstall.cmake.in * Used by _install.cmake_ when creating the `uninstall` target -* update_files.py - * Creates _files.cmake_ from _$(wx)/build/files_ Sub directories --------------- From 89148ea72e52f1e20a3f39ed5fd65fd4fd85956c Mon Sep 17 00:00:00 2001 From: Tobias Taschner Date: Mon, 5 Feb 2018 22:04:55 +0100 Subject: [PATCH 3/4] CMake: Improve documentation overview page --- docs/doxygen/overviews/cmake.md | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/docs/doxygen/overviews/cmake.md b/docs/doxygen/overviews/cmake.md index e1b11586bb..1257ed086b 100644 --- a/docs/doxygen/overviews/cmake.md +++ b/docs/doxygen/overviews/cmake.md @@ -62,13 +62,29 @@ Build options {#cmake_options} The following list of build options can either be configured in the CMake UI or specified via the -D command line option when running the cmake command. -Option Name | Type | Description ------------------------------ | ----- | ------------------------------------ -wxBUILD_SHARED | BOOL | Build shared libraries -wxBUILD_TESTS | STRING | CONSOLE_ONLY, ALL or OFF -wxBUILD_SAMPLES | STRING | SOME, ALL or OFF -wxUSE_GUI | BOOL | Build the UI libraries -wxBUILD_COMPATIBILITY | STRING | 2.8, 3.0 or 3.1 API compatibility +Option Name | Type | Default | Description +------------------------- | ----- | ------- | ---------------------------- +wxBUILD_SHARED | BOOL | ON | Build shared libraries +wxBUILD_TESTS | STRING | OFF | CONSOLE_ONLY, ALL or OFF +wxBUILD_SAMPLES | STRING | OFF | SOME, ALL or OFF +wxBUILD_DEMOS | BOOL | OFF | Build demo applications +wxUSE_GUI | BOOL | ON | Build the UI libraries +wxBUILD_COMPATIBILITY | STRING | 3.0 | 2.8, 3.0 or 3.1 API compatibility +wxBUILD_PRECOMP | BOOL | ON | Use precompiled headers +wxBUILD_MONOLITHIC | BOOL | OFF | Build a single library + +A complete list of options and advanced options can be found when using the +CMake GUI. + +Recommendations {#cmake_recommendations} +======================= +While CMake in wxWidgets aims to support most generators available +in CMake the following generators are recommended: +* Windows: Visual Studio (any supported version) +* macOS: Xcode +* Linux: Ninja or Makefiles + +CMake 3.10 or newer is recommended. The minimum version required is 2.8.12. Using CMake with your applications {#cmake_apps} ================================== From 0a94c1890f83532ce5b6801c019ff7d25b9f11ad Mon Sep 17 00:00:00 2001 From: Tobias Taschner Date: Tue, 6 Feb 2018 10:24:48 +0100 Subject: [PATCH 4/4] CMake: Fixes/Tweaks for macOS building with C++ 11 Make sure the deployment target is set to 10.9 when using C++11 Also ensure building C++11 on macOS for non Xcode builds --- CMakeLists.txt | 7 ++++++- build/cmake/functions.cmake | 10 ++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a067b00356..21ae14c342 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,7 +20,12 @@ endif() if(APPLE AND NOT CMAKE_OSX_DEPLOYMENT_TARGET) # If no deployment target has been set default to the minimum supported # OS X version (this has to be set before the first project() call) - set(CMAKE_OSX_DEPLOYMENT_TARGET 10.7 CACHE STRING "OS X Deployment Target") + if(CMAKE_CXX_STANDARD EQUAL 11 OR CMAKE_CXX_STANDARD EQUAL 14) + set(OSX_DEFAULT_DEPLOYMENT_TARGET 10.9) + else() + set(OSX_DEFAULT_DEPLOYMENT_TARGET 10.7) + endif() + set(CMAKE_OSX_DEPLOYMENT_TARGET ${OSX_DEFAULT_DEPLOYMENT_TARGET} CACHE STRING "OS X Deployment Target") endif() project(wxWidgets) diff --git a/build/cmake/functions.cmake b/build/cmake/functions.cmake index 23c68ee76d..6cf1faf00d 100644 --- a/build/cmake/functions.cmake +++ b/build/cmake/functions.cmake @@ -74,7 +74,13 @@ function(wx_set_common_target_properties target_name) # TODO: implement for older CMake versions ? set_target_properties(${target_name} PROPERTIES CXX_STANDARD ${wxBUILD_CXX_STANDARD}) if(wxBUILD_CXX_STANDARD EQUAL 11 OR wxBUILD_CXX_STANDARD EQUAL 14) - set_target_properties(${target_name} PROPERTIES XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY libc++) + if (APPLE) + if(CMAKE_GENERATOR EQUAL "Xcode") + set_target_properties(${target_name} PROPERTIES XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY libc++) + else() + target_compile_options(${target_name} PUBLIC "-stdlib=libc++") + endif() + endif() #TODO: define for other generators than Xcode endif() endif() @@ -304,7 +310,7 @@ endfunction() # Enable cotire for target if precompiled headers are enabled macro(wx_target_enable_precomp target_name) if(wxBUILD_PRECOMP) - if(CMAKE_GENERATOR STREQUAL "Xcode" AND ${target_name} STREQUAL "wxscintilla") + if(APPLE AND ${target_name} STREQUAL "wxscintilla") # TODO: workaround/fix cotire issue with wxscintilla when using Xcode else() set_target_properties(${target_name} PROPERTIES COTIRE_ADD_UNITY_BUILD FALSE)