mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-22 13:18:28 +00:00
Cmake build: Fine tuning
1.) If building with external iconv, remove remnants of libiconv data created if previousy used internal iconv 2.) Remove the variable HELP from cache to enable subsequent builds. (Different variable-handling on new cmake (version >= 3.18)) 3.) New macro to extract cmake-known-cxx-sts features 4.) Check for CXX11-features only for a subset of possibilities known by the used cmake
This commit is contained in:
parent
33228178a8
commit
2ec243d47b
@ -2,13 +2,11 @@
|
||||
# Licence details can be found in the file COPYING.
|
||||
#
|
||||
# Copyright (c) 2006-2011 Peter Kümmel, <syntheticpp@gmx.net>
|
||||
# Copyright (c) 2008-2011 Kornel Benko, <Kornel.Benko@berlin.de>
|
||||
# Copyright (c) 2008-2020 Kornel Benko, <Kornel.Benko@berlin.de>
|
||||
|
||||
cmake_minimum_required(VERSION 3.1.0)
|
||||
|
||||
set(GNUWIN32_DIR D:/LyX/lyx-unstable/lyx-windows-deps-msvc2017)
|
||||
set(LYX_USE_QT "QT5")
|
||||
set(LYX_REQUIRE_SPELLCHECK true)
|
||||
|
||||
set(LYX_PROJECT LyX)
|
||||
# Instruct cmake to not use gnu extensions,
|
||||
@ -54,6 +52,9 @@ if(COMMAND cmake_policy)
|
||||
if(POLICY CMP0075)
|
||||
cmake_policy(SET CMP0075 NEW)
|
||||
endif()
|
||||
if(POLICY CMP0077)
|
||||
cmake_policy(SET CMP0077 NEW)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS true)
|
||||
@ -258,6 +259,8 @@ if(help OR HELP)
|
||||
message(STATUS)
|
||||
LYX_OPTION_LIST_ALL(help)
|
||||
message(STATUS)
|
||||
unset(help CACHE)
|
||||
unset(HELP CACHE)
|
||||
RETURN()
|
||||
endif()
|
||||
|
||||
@ -696,28 +699,16 @@ else()
|
||||
# This allows us to use QT5.7 with recent g++ (version >= 4.9) compilers
|
||||
# and still use our own c++ extension tests
|
||||
set(std_num ${CMAKE_MATCH_1})
|
||||
# Try to find a std-cxx-feature supported by this cmake version
|
||||
while (std_num GREATER 0)
|
||||
list(FIND CMAKE_CXX_COMPILE_FEATURES "cxx_std_${std_num}" stdfeature)
|
||||
if (stdfeature GREATER -1)
|
||||
set(CMAKE_CXX_STANDARD ${std_num})
|
||||
break()
|
||||
endif()
|
||||
math(EXPR std_num "${std_num}-1")
|
||||
endwhile()
|
||||
message(STATUS "std_num = ${std_num}")
|
||||
if (std_num EQUAL 0)
|
||||
# not found appropriate feature
|
||||
# so we use LYX_GCC11_MODE
|
||||
set(LYX_CXX_FLAGS "-Wall -Wunused-parameter ${LYX_GCC11_MODE}${LYX_CXX_FLAGS}")
|
||||
else()
|
||||
message(STATUS "CMAKE_CXX_STANDARD set to ${CMAKE_CXX_STANDARD}")
|
||||
set(LYX_CXX_FLAGS "-Wall -Wunused-parameter ${LYX_CXX_FLAGS}")
|
||||
endif()
|
||||
message(STATUS "Setting LYX_CXX_FLAGS to ${LYX_CXX_FLAGS}")
|
||||
set(CMAKE_CXX_STANDARD ${std_num})
|
||||
else()
|
||||
set(LYX_CXX_FLAGS "-Wall -Wunused-parameter ${LYX_GCC11_MODE}${LYX_CXX_FLAGS}")
|
||||
message(STATUS "Setting CMAKE_CXX_STANDARD 11 as fallback")
|
||||
set(CMAKE_CXX_STANDARD 11)
|
||||
set(LYX_GCC11_MODE "--std=c++11")
|
||||
endif()
|
||||
# The following setting with LYX_GCC11_MODE is needed because cmake does not honor
|
||||
# CMAKE_CXX_STANDARD while performing tests like
|
||||
# check_cxx_source_compiles("..." HAVE_DEF_MAKE_UNIQUE)
|
||||
set(LYX_CXX_FLAGS "-Wall -Wunused-parameter ${LYX_GCC11_MODE}${LYX_CXX_FLAGS}")
|
||||
if(LYX_STDLIB_DEBUG)
|
||||
set(LYX_CXX_FLAGS "${LYX_CXX_FLAGS} -D_GLIBCXX_DEBUG -D_GLIBCXX_DEBUG_PEDANTIC")
|
||||
else()
|
||||
@ -940,6 +931,8 @@ if(LYX_NLS)
|
||||
endif()
|
||||
|
||||
if(LYX_EXTERNAL_ICONV)
|
||||
# Possible remnants of previous run without external iconv
|
||||
file(REMOVE_RECURSE "${CMAKE_BINARY_DIR}/libiconv" "${CMAKE_BINARY_DIR}/3rdparty/libiconv")
|
||||
find_package(ICONV REQUIRED)
|
||||
else()
|
||||
add_subdirectory(3rdparty/libiconv)
|
||||
|
@ -34,11 +34,21 @@
|
||||
INCLUDE(CheckCXXSourceCompiles)
|
||||
INCLUDE(FindPackageHandleStandardArgs)
|
||||
|
||||
# get cmake-known std numbers
|
||||
# Detection of c++20 works well, but our code is not ready for it yet.
|
||||
# We currently get errors with internal boost and also from our code.
|
||||
set(_max_std_num 17)
|
||||
lyxgetknowncmakestd(${_max_std_num} tmpnums)
|
||||
|
||||
if (CMAKE_CXX_COMPILER_ID MATCHES "^([cC]lang|AppleClang)$")
|
||||
set(CXX11_FLAG_CANDIDATES "--std=c++11 -Wno-deprecated-register")
|
||||
foreach(_num ${tmpnums})
|
||||
list(APPEND CXX11_FLAG_CANDIDATES "--std=c++${_num} -Wno-deprecated-register")
|
||||
endforeach()
|
||||
else()
|
||||
if (CYGWIN)
|
||||
set(CXX11_FLAG_CANDIDATES "--std=gnu++11")
|
||||
foreach(_num ${tmpnums})
|
||||
list(APPEND CXX11_FLAG_CANDIDATES "--std=gnu++${_num}")
|
||||
endforeach()
|
||||
else()
|
||||
if (MSVC)
|
||||
# MSVC does not have a general C++11 flag, one can only switch off
|
||||
@ -47,22 +57,16 @@ else()
|
||||
if (MSVC_VERSION LESS 1926)
|
||||
set(CXX11_FLAG_CANDIDATES "noflagneeded")
|
||||
else()
|
||||
set(CXX11_FLAG_CANDIDATES
|
||||
"/std:c++17"
|
||||
"/std:c++14"
|
||||
"noflagneeded")
|
||||
foreach(_num ${tmpnums})
|
||||
list(APPEND CXX11_FLAG_CANDIDATES "/std:c++${_num}")
|
||||
endforeach()
|
||||
list(APPEND CXX11_FLAG_CANDIDATES "noflagneeded")
|
||||
endif()
|
||||
else()
|
||||
set(CXX11_FLAG_CANDIDATES
|
||||
# Detection of c++20 works well, but our code is not ready for it yet.
|
||||
# We currently get errors with internal boost and also from our code.
|
||||
# "--std=c++20"
|
||||
"--std=c++17"
|
||||
"--std=c++14"
|
||||
"--std=c++11"
|
||||
"--std=gnu++11"
|
||||
"--std=gnu++0x"
|
||||
)
|
||||
set(CXX11_FLAG_CANDIDATES)
|
||||
foreach(_num ${tmpnums})
|
||||
list(APPEND CXX11_FLAG_CANDIDATES "--std=c++${_num}")
|
||||
endforeach()
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
@ -288,20 +288,22 @@ macro(LYX_OPTION_LIST_ALL)
|
||||
file(APPEND ${run_cmake} " -G\"${CMAKE_GENERATOR}\" ${cont}")
|
||||
foreach(_option ${LYX_OPTIONS})
|
||||
if(${_option}_show_message OR ${ARGV0} STREQUAL "help")
|
||||
string(SUBSTRING "${_option} " 0 31 _var)
|
||||
get_property(_prop CACHE ${_option} PROPERTY STRINGS)
|
||||
list(FIND LYX_OPTION_STRINGS ${_option} _index)
|
||||
set(_type "BOOL")
|
||||
if (${_index} GREATER -1)
|
||||
#message(STATUS "${_option} is of type string")
|
||||
set(_isset ${${_option}})
|
||||
set(_type "STRING")
|
||||
elseif(${_option})
|
||||
set(_isset ON)
|
||||
else()
|
||||
set(_isset OFF)
|
||||
endif()
|
||||
string(SUBSTRING "${_isset} " 0 10 _val)
|
||||
string(SUBSTRING "${_option}:${_type} " 0 35 _var)
|
||||
string(SUBSTRING "${_isset} " 0 7 _val)
|
||||
message(STATUS "${_var}= ${_val}: ${${_option}_description}")
|
||||
file(APPEND ${run_cmake} " -D${_option}=${${_option}} ${cont}")
|
||||
file(APPEND ${run_cmake} " -D${_option}:${_type}=${${_option}} ${cont}")
|
||||
endif()
|
||||
endforeach()
|
||||
file(APPEND ${run_cmake} "\n")
|
||||
@ -396,7 +398,7 @@ function(find_python_module module)
|
||||
ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
if(NOT _${module}_status)
|
||||
set(LYX_PY_${module_upper} ${_${module}_location} CACHE STRING
|
||||
"Location of Python module ${module}")
|
||||
"Location of Python module ${module}")
|
||||
endif()
|
||||
endif()
|
||||
find_package_handle_standard_args(LYX_PY_${module} DEFAULT_MSG LYX_PY_${module_upper})
|
||||
@ -433,20 +435,20 @@ function(determineversionandbuildtype configfile package version dirs date build
|
||||
setstripped(PACKAGE_BUGREPORT ${_PBU})
|
||||
set(${package} ${PACKAGE_BASE} ${PACKAGE_VERSION} ${PACKAGE_BUGREPORT} PARENT_SCOPE)
|
||||
if(PACKAGE_VERSION MATCHES "^\([0-9]+\)\\.\([0-9]+\)\(\\.\([0-9]+\)\(\\.\([0-9]+\)\)?\)?\([a-z]*\).*$")
|
||||
set(LYX_MAJOR_VERSION ${CMAKE_MATCH_1})
|
||||
set(LYX_MINOR_VERSION ${CMAKE_MATCH_2})
|
||||
set(LYX_RELEASE_LEVEL ${CMAKE_MATCH_4})
|
||||
set(LYX_RELEASE_PATCH ${CMAKE_MATCH_6})
|
||||
set(LYX_BUILD_TYPE ${CMAKE_MATCH_7})
|
||||
set(LYX_DIR_VER "LYX_DIR_${CMAKE_MATCH_1}${CMAKE_MATCH_2}x")
|
||||
set(LYX_USERDIR_VER "LYX_USERDIR_${CMAKE_MATCH_1}${CMAKE_MATCH_2}x")
|
||||
if (NOT LYX_RELEASE_LEVEL)
|
||||
set(LYX_RELEASE_LEVEL 0)
|
||||
endif()
|
||||
if (NOT LYX_RELEASE_PATCH)
|
||||
set(LYX_RELEASE_PATCH 0)
|
||||
endif()
|
||||
set(LYX_VERSION "${LYX_MAJOR_VERSION}.${LYX_MINOR_VERSION}")
|
||||
set(LYX_MAJOR_VERSION ${CMAKE_MATCH_1})
|
||||
set(LYX_MINOR_VERSION ${CMAKE_MATCH_2})
|
||||
set(LYX_RELEASE_LEVEL ${CMAKE_MATCH_4})
|
||||
set(LYX_RELEASE_PATCH ${CMAKE_MATCH_6})
|
||||
set(LYX_BUILD_TYPE ${CMAKE_MATCH_7})
|
||||
set(LYX_DIR_VER "LYX_DIR_${CMAKE_MATCH_1}${CMAKE_MATCH_2}x")
|
||||
set(LYX_USERDIR_VER "LYX_USERDIR_${CMAKE_MATCH_1}${CMAKE_MATCH_2}x")
|
||||
if (NOT LYX_RELEASE_LEVEL)
|
||||
set(LYX_RELEASE_LEVEL 0)
|
||||
endif()
|
||||
if (NOT LYX_RELEASE_PATCH)
|
||||
set(LYX_RELEASE_PATCH 0)
|
||||
endif()
|
||||
set(LYX_VERSION "${LYX_MAJOR_VERSION}.${LYX_MINOR_VERSION}")
|
||||
endif()
|
||||
endif()
|
||||
if(_c_l MATCHES "^AC_SUBST\\( *LYX_DATE *, *\\[\\\"(.*)\\\"\\].*")
|
||||
@ -467,3 +469,28 @@ function(determineversionandbuildtype configfile package version dirs date build
|
||||
message(FATAL_ERROR "\"${configfile}\": Unable to determine build-type from suffix \"${LYX_BUILD_TYPE}\" in AC_INIT macro")
|
||||
endif()
|
||||
endfunction(determineversionandbuildtype)
|
||||
|
||||
# determine known cmake cxx_std features but only if not greater than ${max_desired}
|
||||
function(lyxgetknowncmakestd max_desired result)
|
||||
set(tmp_list)
|
||||
set(CXX_STD_LIST)
|
||||
math(EXPR max_desired "${max_desired}+1")
|
||||
if (CMAKE_VERSION VERSION_LESS "3.9")
|
||||
list(APPEND tmp_list 98 11 14)
|
||||
else()
|
||||
foreach(_e ${CMAKE_CXX_COMPILE_FEATURES})
|
||||
if (_e MATCHES "^cxx_std_\(.*)")
|
||||
list(APPEND tmp_list ${CMAKE_MATCH_1})
|
||||
endif()
|
||||
endforeach()
|
||||
endif()
|
||||
list(REVERSE tmp_list)
|
||||
# Filter undesired from list
|
||||
foreach(i ${tmp_list})
|
||||
if (i LESS ${max_desired} OR i GREATER 89)
|
||||
list(APPEND CXX_STD_LIST ${i})
|
||||
endif()
|
||||
endforeach()
|
||||
set(${result} ${CXX_STD_LIST} PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user