Compare commits

..

No commits in common. "e1badf6f69c61a1a2a5aa9ae4aadebcea94df617" and "366902c0a36e9136b9f5f65fdc3b8868cebf60bb" have entirely different histories.

3 changed files with 52 additions and 40 deletions

View File

@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.0)
project(myx-cmake VERSION 0.5.5 LANGUAGES)
project(myx-cmake VERSION 0.5.3 LANGUAGES)
include(GNUInstallDirs)
file(WRITE ${CMAKE_SOURCE_DIR}/MyxCMake/MyxCMakeConfigVersion.cmake

View File

@ -1,4 +1,5 @@
function(myx_cmake_common_target_properties target)
function(myx_cmake_compile_target_properties target)
if(NOT TARGET ${target})
myx_cmake_message_error("MyxCMake: Target ${target} does not exists.")
endif()
@ -48,8 +49,6 @@ function(myx_cmake_common_target_properties target)
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>
$<BUILD_INTERFACE:${CMAKE_BINARY_DIR}/include>)
endif()
target_compile_features(${target} ${__visibility} cxx_alias_templates cxx_nullptr cxx_override)
if(_target_type STREQUAL EXECUTABLE)
set_target_properties(${target} PROPERTIES
@ -69,6 +68,8 @@ function(myx_cmake_common_target_properties target)
set_target_properties(${target} PROPERTIES POSITION_INDEPENDENT_CODE ON)
endif()
endif()
# LTO only for executables (not libraries) in Release build type
if(_target_type STREQUAL EXECUTABLE AND CMAKE_BUILD_TYPE STREQUAL Release)
check_cxx_compiler_flag(-flto CXX_HAS_LTO_FLAG)
@ -104,6 +105,12 @@ function(myx_cmake_common_target_properties target)
target_compile_definitions(
${target} ${__visibility}
"MYX_CMAKE_LSB_CODENAME_${MYX_CMAKE_LSB_CODENAME}")
endfunction()
function(myx_cmake_common_target_properties target)
myx_cmake_compile_target_properties(${target})
myx_cmake_analyze_clang_tidy(${target})
myx_cmake_analyze_clang_check(${target})
@ -150,6 +157,35 @@ function(myx_cmake_common_target_properties target)
endif()
endfunction()
function(myx_cmake_qt_autogen_target_properties target)
myx_cmake_compile_target_properties(${target})
get_target_property(_target_type ${target} TYPE)
if(NOT _target_type STREQUAL OBJECT_LIBRARY)
myx_cmake_message_error("MyxCMake: Target ${target} must have type OBJECT ${_target_type}.")
endif()
get_target_property(__sources ${target} SOURCES)
foreach(src IN LISTS __sources)
string(REGEX MATCH ".*/ui_.*\\.h$" __ui ${src})
if(__ui)
target_include_directories(${target} SYSTEM PUBLIC ${Qt5Widgets_INCLUDE_DIRS})
endif()
endforeach()
foreach(src IN LISTS __sources)
string(REGEX MATCH ".*/moc_.*\\.cpp$" __moc ${src})
if(__moc)
target_include_directories(${target} SYSTEM PUBLIC ${Qt5Core_INCLUDE_DIRS})
endif()
endforeach()
set_target_properties(${target} PROPERTIES CXX_CLANG_TIDY "")
endfunction()
function(myx_cmake_common_target_properties_post_link target)
if(NOT TARGET ${target})
myx_cmake_message_error("MyxCMake: Target ${target} does not exists.")

View File

@ -3,7 +3,7 @@
#
# Version 12
cmake_minimum_required(VERSION 3.0.0)
cmake_minimum_required(VERSION 2.8.12)
cmake_policy(SET CMP0054 NEW)
if (PVS_STUDIO_AS_SCRIPT)
@ -31,8 +31,7 @@ if (PVS_STUDIO_AS_SCRIPT)
endif ()
endif ()
endforeach ()
file(REMOVE "${PVS_STUDIO_LOG_FILE}")
execute_process(COMMAND ${PVS_STUDIO_COMMAND} ${additional_args}
RESULT_VARIABLE result
OUTPUT_VARIABLE output
@ -59,17 +58,13 @@ function (pvs_studio_log TEXT)
endfunction ()
function (pvs_studio_relative_path VAR ROOT FILEPATH)
if (WIN32)
STRING(REGEX REPLACE "\\\\" "/" ROOT ${ROOT})
STRING(REGEX REPLACE "\\\\" "/" FILEPATH ${FILEPATH})
endif()
set("${VAR}" "${FILEPATH}" PARENT_SCOPE)
if (IS_ABSOLUTE "${FILEPATH}")
if ("${FILEPATH}" MATCHES "^/.*$" OR "${FILEPATH}" MATCHES "^.:/.*$")
file(RELATIVE_PATH RPATH "${ROOT}" "${FILEPATH}")
if (NOT IS_ABSOLUTE "${RPATH}")
if (NOT "${RPATH}" MATCHES "^\\.\\..*$")
set("${VAR}" "${RPATH}" PARENT_SCOPE)
endif()
endif()
endif ()
endif ()
endfunction ()
function (pvs_studio_join_path VAR DIR1 DIR2)
@ -101,7 +96,7 @@ macro (pvs_studio_append_flags_from_property CXX C DIR PREFIX)
endmacro ()
macro (pvs_studio_append_standard_flag FLAGS STANDARD)
if ("${STANDARD}" MATCHES "^(99|11|14|17|20)$")
if ("${STANDARD}" MATCHES "^(99|11|14|17)$")
if ("${PVS_STUDIO_PREPROCESSOR}" MATCHES "gcc|clang")
list(APPEND "${FLAGS}" "-std=c++${STANDARD}")
endif ()
@ -210,9 +205,8 @@ function (pvs_studio_analyze_file SOURCE SOURCE_DIR BINARY_DIR)
string(REPLACE ";" "$<SEMICOLON>" cmdline "${cmdline}")
set(pvscmd "${CMAKE_COMMAND}"
-D "PVS_STUDIO_AS_SCRIPT=TRUE"
-D PVS_STUDIO_AS_SCRIPT=TRUE
-D "PVS_STUDIO_COMMAND=${cmdline}"
-D "PVS_STUDIO_LOG_FILE=${LOG}"
-P "${PVS_STUDIO_SCRIPT}"
)
@ -519,14 +513,10 @@ function (pvs_studio_add_target)
if ("${PVS_STUDIO_FORMAT}" STREQUAL "")
set(PVS_STUDIO_FORMAT "errorfile")
endif ()
set(converter_no_help "")
if (PVS_STUDIO_HIDE_HELP)
set(converter_no_help "--noHelpMessages")
endif()
list(APPEND COMMANDS
COMMAND "${CMAKE_COMMAND}" -E remove -f "${PVS_STUDIO_LOG}.pvs.raw"
COMMAND "${CMAKE_COMMAND}" -E rename "${PVS_STUDIO_LOG}" "${PVS_STUDIO_LOG}.pvs.raw"
COMMAND "${PVS_STUDIO_CONVERTER}" "${PVS_STUDIO_CONVERTER_ARGS}" ${converter_no_help} -t "${PVS_STUDIO_FORMAT}" "${PVS_STUDIO_LOG}.pvs.raw" -o "${PVS_STUDIO_LOG}" -a "${PVS_STUDIO_MODE}"
COMMAND "${PVS_STUDIO_CONVERTER}" "${PVS_STUDIO_CONVERTER_ARGS}" -t "${PVS_STUDIO_FORMAT}" "${PVS_STUDIO_LOG}.pvs.raw" -o "${PVS_STUDIO_LOG}" -a "${PVS_STUDIO_MODE}"
)
if(NOT PVS_STUDIO_KEEP_COMBINED_PLOG)
list(APPEND COMMANDS COMMAND "${CMAKE_COMMAND}" -E remove -f "${PVS_STUDIO_LOG}.pvs.raw")
@ -554,7 +544,9 @@ function (pvs_studio_add_target)
endif ()
if (PVS_STUDIO_OUTPUT)
if (WIN32)
if (PVS_STUDIO_HIDE_HELP AND NOT WIN32)
set(COMMANDS COMMAND grep -v " error: Help:" ${PVS_STUDIO_LOG} 1>&2 || exit 0)
elseif (WIN32)
set(COMMANDS COMMAND type "${PVS_STUDIO_LOG}" 1>&2)
else ()
set(COMMANDS COMMAND cat "${PVS_STUDIO_LOG}" 1>&2)
@ -563,25 +555,9 @@ function (pvs_studio_add_target)
set(COMMANDS "")
endif ()
set(props_file "${CMAKE_BINARY_DIR}/${PVS_STUDIO_TARGET}.user.props")
file(WRITE "${props_file}" [=[
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ImportGroup Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ItemDefinitionGroup>
<CustomBuild>
<BuildInParallel>true</BuildInParallel>
</CustomBuild>
</ItemDefinitionGroup>
</Project>
]=])
add_custom_target("${PVS_STUDIO_TARGET}" ${ALL} ${COMMANDS}
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}"
DEPENDS ${PVS_STUDIO_DEPENDS} "${PVS_STUDIO_LOG}")
set_target_properties("${PVS_STUDIO_TARGET}" PROPERTIES VS_USER_PROPS "${props_file}")
# A workaround to add implicit dependencies of source files from include directories
set_target_properties("${PVS_STUDIO_TARGET}" PROPERTIES INCLUDE_DIRECTORIES "${inc_path}")