diff --git a/CMakeLists.txt b/CMakeLists.txt index 42be0430e7..21ae14c342 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,10 +9,23 @@ 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) - 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/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 --------------- 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) 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} ==================================