Minor CMake and CMake documentation improvements.

See https://github.com/wxWidgets/wxWidgets/pull/720
This commit is contained in:
Vadim Zeitlin
2018-02-06 17:00:58 +01:00
4 changed files with 50 additions and 16 deletions

View File

@@ -9,10 +9,23 @@
cmake_minimum_required(VERSION 2.8.12) 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(APPLE AND NOT CMAKE_OSX_DEPLOYMENT_TARGET)
# If no deployment target has been set default to the minimum supported # 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) # 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() endif()
project(wxWidgets) project(wxWidgets)

View File

@@ -7,7 +7,7 @@ documentation.
CMake files organization 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. _CMakeLists.txt_ in the root directory.
Files Files
@@ -19,15 +19,16 @@ Files
* Generates config files used to find wxWidgets by other build systems * Generates config files used to find wxWidgets by other build systems
* Creates wx-config * Creates wx-config
* files.cmake * files.cmake
* List of source files generated by _update_files.py_ from _$(wx)/build/files_ * List of source files generated by _$(wx)build/upmake_ from _$(wx)build/files_
* This file should **never** be edited manually * 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 * functions.cmake
* contains various wxWidgets specific functions and macros used throughout * contains various wxWidgets specific functions and macros used throughout
the CMake files the CMake files
* Every function should contain a short description of it's parameters as * Every function should contain a short description of it's parameters as
a comment before the function/macro a comment before the function/macro
* install.cmake * install.cmake
* Handles defintions for the ´install` and `uninstall` target * Handles defintions for the `install` and `uninstall` target
* init.cmake * init.cmake
* Intializes various variables used during the build process and for * Intializes various variables used during the build process and for
generation of setup.h and configuration files generation of setup.h and configuration files
@@ -49,8 +50,6 @@ Files
* Define toolkit specific options and detection to this file * Define toolkit specific options and detection to this file
* uninstall.cmake.in * uninstall.cmake.in
* Used by _install.cmake_ when creating the `uninstall` target * Used by _install.cmake_ when creating the `uninstall` target
* update_files.py
* Creates _files.cmake_ from _$(wx)/build/files_
Sub directories Sub directories
--------------- ---------------

View File

@@ -74,7 +74,13 @@ function(wx_set_common_target_properties target_name)
# TODO: implement for older CMake versions ? # TODO: implement for older CMake versions ?
set_target_properties(${target_name} PROPERTIES CXX_STANDARD ${wxBUILD_CXX_STANDARD}) set_target_properties(${target_name} PROPERTIES CXX_STANDARD ${wxBUILD_CXX_STANDARD})
if(wxBUILD_CXX_STANDARD EQUAL 11 OR wxBUILD_CXX_STANDARD EQUAL 14) 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 #TODO: define for other generators than Xcode
endif() endif()
endif() endif()
@@ -304,7 +310,7 @@ endfunction()
# Enable cotire for target if precompiled headers are enabled # Enable cotire for target if precompiled headers are enabled
macro(wx_target_enable_precomp target_name) macro(wx_target_enable_precomp target_name)
if(wxBUILD_PRECOMP) 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 # TODO: workaround/fix cotire issue with wxscintilla when using Xcode
else() else()
set_target_properties(${target_name} PROPERTIES COTIRE_ADD_UNITY_BUILD FALSE) set_target_properties(${target_name} PROPERTIES COTIRE_ADD_UNITY_BUILD FALSE)

View File

@@ -62,13 +62,29 @@ Build options {#cmake_options}
The following list of build options can either be configured in the CMake UI 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. or specified via the -D command line option when running the cmake command.
Option Name | Type | Description Option Name | Type | Default | Description
----------------------------- | ----- | ------------------------------------ ------------------------- | ----- | ------- | ----------------------------
wxBUILD_SHARED | BOOL | Build shared libraries wxBUILD_SHARED | BOOL | ON | Build shared libraries
wxBUILD_TESTS | STRING | CONSOLE_ONLY, ALL or OFF wxBUILD_TESTS | STRING | OFF | CONSOLE_ONLY, ALL or OFF
wxBUILD_SAMPLES | STRING | SOME, ALL or OFF wxBUILD_SAMPLES | STRING | OFF | SOME, ALL or OFF
wxUSE_GUI | BOOL | Build the UI libraries wxBUILD_DEMOS | BOOL | OFF | Build demo applications
wxBUILD_COMPATIBILITY | STRING | 2.8, 3.0 or 3.1 API compatibility 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} Using CMake with your applications {#cmake_apps}
================================== ==================================