parent
c6cce43757
commit
9ce4323380
48
utils.cmake
48
utils.cmake
|
@ -39,8 +39,8 @@ function(setup_project)
|
||||||
if(POLICY CMP0141)
|
if(POLICY CMP0141)
|
||||||
cmake_policy(SET CMP0141 NEW)
|
cmake_policy(SET CMP0141 NEW)
|
||||||
endif()
|
endif()
|
||||||
# Introduced by CMP0141. Will be ignored if compiler is not MSVC, so it's fine to set it globally.
|
# Introduced by CMP0141.
|
||||||
if(NOT DEFINED CMAKE_MSVC_DEBUG_INFORMATION_FORMAT)
|
if(MSVC AND NOT DEFINED CMAKE_MSVC_DEBUG_INFORMATION_FORMAT)
|
||||||
set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT "$<$<CONFIG:Debug,RelWithDebInfo>:ProgramDatabase>" PARENT_SCOPE)
|
set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT "$<$<CONFIG:Debug,RelWithDebInfo>:ProgramDatabase>" PARENT_SCOPE)
|
||||||
endif()
|
endif()
|
||||||
# Improve language standard and extension selection.
|
# Improve language standard and extension selection.
|
||||||
|
@ -75,17 +75,17 @@ function(setup_project)
|
||||||
if(POLICY CMP0091)
|
if(POLICY CMP0091)
|
||||||
cmake_policy(SET CMP0091 NEW)
|
cmake_policy(SET CMP0091 NEW)
|
||||||
endif()
|
endif()
|
||||||
# Introduced by CMP0091. Will be ignored if compiler is not MSVC.
|
# Introduced by CMP0091.
|
||||||
if(NOT DEFINED CMAKE_MSVC_RUNTIME_LIBRARY)
|
if(MSVC AND NOT DEFINED CMAKE_MSVC_RUNTIME_LIBRARY)
|
||||||
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL" PARENT_SCOPE)
|
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL" PARENT_SCOPE)
|
||||||
endif()
|
endif()
|
||||||
# Add correct link flags for PIE (Position Independent Executable).
|
# Add correct link flags for PIE (Position Independent Executable).
|
||||||
if(POLICY CMP0083)
|
if(POLICY CMP0083)
|
||||||
cmake_policy(SET CMP0083 NEW)
|
cmake_policy(SET CMP0083 NEW)
|
||||||
endif()
|
endif()
|
||||||
if(NOT DEFINED CMAKE_BUILD_TYPE)
|
#if(NOT DEFINED CMAKE_BUILD_TYPE)
|
||||||
set(CMAKE_BUILD_TYPE "Release" PARENT_SCOPE)
|
# set(CMAKE_BUILD_TYPE "Release" PARENT_SCOPE)
|
||||||
endif()
|
#endif()
|
||||||
if(PROJ_ARGS_ENABLE_LTO)
|
if(PROJ_ARGS_ENABLE_LTO)
|
||||||
# MinGW has many bugs when LTO is enabled, and they are all very
|
# MinGW has many bugs when LTO is enabled, and they are all very
|
||||||
# hard to workaround, so just don't enable LTO at all for MinGW.
|
# hard to workaround, so just don't enable LTO at all for MinGW.
|
||||||
|
@ -95,9 +95,14 @@ function(setup_project)
|
||||||
endif()
|
endif()
|
||||||
if(NOT DEFINED CMAKE_DEBUG_POSTFIX)
|
if(NOT DEFINED CMAKE_DEBUG_POSTFIX)
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
set(CMAKE_DEBUG_POSTFIX "d" PARENT_SCOPE)
|
if(NOT MINGW) # MinGW libraries usually don't have debug postfix.
|
||||||
|
set(CMAKE_DEBUG_POSTFIX "d" PARENT_SCOPE)
|
||||||
|
endif()
|
||||||
else()
|
else()
|
||||||
set(CMAKE_DEBUG_POSTFIX "_debug" PARENT_SCOPE)
|
set(CMAKE_DEBUG_POSTFIX "_debug" PARENT_SCOPE)
|
||||||
|
if(APPLE)
|
||||||
|
set(CMAKE_FRAMEWORK_MULTI_CONFIG_POSTFIX_DEBUG "_debug" PARENT_SCOPE)
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
if(NOT DEFINED CMAKE_RUNTIME_OUTPUT_DIRECTORY)
|
if(NOT DEFINED CMAKE_RUNTIME_OUTPUT_DIRECTORY)
|
||||||
|
@ -110,6 +115,21 @@ function(setup_project)
|
||||||
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/lib" PARENT_SCOPE)
|
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/lib" PARENT_SCOPE)
|
||||||
endif()
|
endif()
|
||||||
set(CMAKE_INCLUDE_CURRENT_DIR ON PARENT_SCOPE)
|
set(CMAKE_INCLUDE_CURRENT_DIR ON PARENT_SCOPE)
|
||||||
|
set(CMAKE_LINK_DEPENDS_NO_SHARED ON PARENT_SCOPE)
|
||||||
|
set(CMAKE_POSITION_INDEPENDENT_CODE ON PARENT_SCOPE)
|
||||||
|
include(CheckPIESupported)
|
||||||
|
check_pie_supported() # This function must be called to ensure CMake adds -fPIE to the linker flags.
|
||||||
|
set(CMAKE_VISIBILITY_INLINES_HIDDEN ON PARENT_SCOPE)
|
||||||
|
if(PROJ_ARGS_QT_PROJECT)
|
||||||
|
set(CMAKE_AUTOUIC ON PARENT_SCOPE)
|
||||||
|
set(CMAKE_AUTOMOC ON PARENT_SCOPE)
|
||||||
|
set(CMAKE_AUTORCC ON PARENT_SCOPE)
|
||||||
|
endif()
|
||||||
|
if(PROJ_ARGS_QML_IMPORT_DIR)
|
||||||
|
list(APPEND QML_IMPORT_PATH "${PROJ_ARGS_QML_IMPORT_DIR}")
|
||||||
|
list(REMOVE_DUPLICATES QML_IMPORT_PATH)
|
||||||
|
set(QML_IMPORT_PATH ${QML_IMPORT_PATH} CACHE STRING "Qt Creator extra QML import paths" FORCE)
|
||||||
|
endif()
|
||||||
foreach(__lang ${PROJ_ARGS_LANGUAGES})
|
foreach(__lang ${PROJ_ARGS_LANGUAGES})
|
||||||
if(__lang STREQUAL "C")
|
if(__lang STREQUAL "C")
|
||||||
enable_language(C)
|
enable_language(C)
|
||||||
|
@ -238,18 +258,6 @@ function(setup_project)
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
endforeach()
|
endforeach()
|
||||||
set(CMAKE_POSITION_INDEPENDENT_CODE ON PARENT_SCOPE)
|
|
||||||
set(CMAKE_VISIBILITY_INLINES_HIDDEN ON PARENT_SCOPE)
|
|
||||||
if(PROJ_ARGS_QT_PROJECT)
|
|
||||||
set(CMAKE_AUTOUIC ON PARENT_SCOPE)
|
|
||||||
set(CMAKE_AUTOMOC ON PARENT_SCOPE)
|
|
||||||
set(CMAKE_AUTORCC ON PARENT_SCOPE)
|
|
||||||
endif()
|
|
||||||
if(PROJ_ARGS_QML_IMPORT_DIR)
|
|
||||||
list(APPEND QML_IMPORT_PATH "${PROJ_ARGS_QML_IMPORT_DIR}")
|
|
||||||
list(REMOVE_DUPLICATES QML_IMPORT_PATH)
|
|
||||||
set(QML_IMPORT_PATH ${QML_IMPORT_PATH} CACHE STRING "Qt Creator extra QML import paths" FORCE)
|
|
||||||
endif()
|
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
function(get_commit_hash)
|
function(get_commit_hash)
|
||||||
|
|
Loading…
Reference in New Issue