Правка добавления флагов
This commit is contained in:
		@@ -7,9 +7,7 @@ function(add_code_coverage target)
 | 
				
			|||||||
  if(CMLIB_ENABLE_CODE_COVERAGE)
 | 
					  if(CMLIB_ENABLE_CODE_COVERAGE)
 | 
				
			||||||
    if(CMAKE_CXX_COMPILER_IS_GCC)
 | 
					    if(CMAKE_CXX_COMPILER_IS_GCC)
 | 
				
			||||||
      target_compile_options(${target} PUBLIC "--coverage")
 | 
					      target_compile_options(${target} PUBLIC "--coverage")
 | 
				
			||||||
      get_target_property(LF ${target} LINK_FLAGS)
 | 
					      set_property(TARGET ${target} APPEND PROPERTY LINK_FLAGS "--coverage")
 | 
				
			||||||
      string(APPEND LF " --coverage")
 | 
					 | 
				
			||||||
      set_target_properties(${target} PROPERTIES LINK_FLAGS ${LF})
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
      if(LCOV_EXE)
 | 
					      if(LCOV_EXE)
 | 
				
			||||||
        add_custom_target(
 | 
					        add_custom_target(
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,9 +1,10 @@
 | 
				
			|||||||
set(COMMON_CXX_FEATURES cxx_alias_templates cxx_nullptr cxx_override)
 | 
					set(COMMON_CXX_FEATURES cxx_alias_templates cxx_nullptr cxx_override)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function(common_target_properties target)
 | 
					function(common_target_properties target)
 | 
				
			||||||
  get_target_property(__type ${target} TYPE)
 | 
					  get_target_property(_targetType ${target} TYPE)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  set(__visibility PUBLIC)
 | 
					  set(__visibility PUBLIC)
 | 
				
			||||||
  if(__type STREQUAL INTERFACE_LIBRARY)
 | 
					  if(_targetType STREQUAL INTERFACE_LIBRARY)
 | 
				
			||||||
    set(__interface 1)
 | 
					    set(__interface 1)
 | 
				
			||||||
    set(__visibility INTERFACE)
 | 
					    set(__visibility INTERFACE)
 | 
				
			||||||
  endif()
 | 
					  endif()
 | 
				
			||||||
@@ -17,7 +18,6 @@ function(common_target_properties target)
 | 
				
			|||||||
  endforeach()
 | 
					  endforeach()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  target_compile_features(${target} ${__visibility} ${COMMON_CXX_FEATURES})
 | 
					  target_compile_features(${target} ${__visibility} ${COMMON_CXX_FEATURES})
 | 
				
			||||||
  get_target_property(_targetType ${target} TYPE)
 | 
					 | 
				
			||||||
  if(_targetType STREQUAL "EXECUTABLE")
 | 
					  if(_targetType STREQUAL "EXECUTABLE")
 | 
				
			||||||
    set_target_properties(${target} PROPERTIES RUNTIME_OUTPUT_DIRECTORY
 | 
					    set_target_properties(${target} PROPERTIES RUNTIME_OUTPUT_DIRECTORY
 | 
				
			||||||
                                               ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_BINDIR})
 | 
					                                               ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_BINDIR})
 | 
				
			||||||
@@ -25,13 +25,16 @@ function(common_target_properties target)
 | 
				
			|||||||
      target_compile_options(${target} PUBLIC "${CMAKE_CXX_COMPILE_OPTIONS_PIE}")
 | 
					      target_compile_options(${target} PUBLIC "${CMAKE_CXX_COMPILE_OPTIONS_PIE}")
 | 
				
			||||||
    endif()
 | 
					    endif()
 | 
				
			||||||
  endif()
 | 
					  endif()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  target_include_directories(
 | 
					  target_include_directories(
 | 
				
			||||||
    ${target}
 | 
					    ${target}
 | 
				
			||||||
    PUBLIC $<INSTALL_INTERFACE:include> $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
 | 
					    PUBLIC $<INSTALL_INTERFACE:include> $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
 | 
				
			||||||
           $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}> $<BUILD_INTERFACE:${CMAKE_BINARY_DIR}/include>)
 | 
					           $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}> $<BUILD_INTERFACE:${CMAKE_BINARY_DIR}/include>)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if(APPLE)
 | 
					  if(APPLE)
 | 
				
			||||||
    target_compile_definitions(${target} ${__visibility} Darwin)
 | 
					    target_compile_definitions(${target} ${__visibility} Darwin)
 | 
				
			||||||
  endif()
 | 
					  endif()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if(NOT __interface)
 | 
					  if(NOT __interface)
 | 
				
			||||||
    if(TARGET Qt5::Core)
 | 
					    if(TARGET Qt5::Core)
 | 
				
			||||||
      if(_targetType STREQUAL "EXECUTABLE")
 | 
					      if(_targetType STREQUAL "EXECUTABLE")
 | 
				
			||||||
@@ -48,28 +51,27 @@ function(common_target_properties target)
 | 
				
			|||||||
      endif()
 | 
					      endif()
 | 
				
			||||||
    endif()
 | 
					    endif()
 | 
				
			||||||
    if(CMAKE_CXX_COMPILER_IS_GCC AND NOT APPLE)
 | 
					    if(CMAKE_CXX_COMPILER_IS_GCC AND NOT APPLE)
 | 
				
			||||||
      set_target_properties(${target} PROPERTIES LINK_FLAGS "-Wl,--no-as-needed")
 | 
					      set_property(TARGET ${target} APPEND PROPERTY LINK_FLAGS "-Wl,--no-as-needed")
 | 
				
			||||||
    endif()
 | 
					    endif()
 | 
				
			||||||
  endif()
 | 
					  endif()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  # LTO only for executables (not libraries) in Release build type
 | 
					  # LTO only for executables (not libraries) in Release build type
 | 
				
			||||||
  get_target_property(target_type ${target} TYPE)
 | 
					  if(_targetType STREQUAL "EXECUTABLE" AND CMAKE_BUILD_TYPE STREQUAL "Release")
 | 
				
			||||||
  if(target_type STREQUAL "EXECUTABLE" AND CMAKE_BUILD_TYPE STREQUAL "Release")
 | 
					 | 
				
			||||||
    check_cxx_compiler_flag(-flto CXX_HAS_LTO_FLAG)
 | 
					    check_cxx_compiler_flag(-flto CXX_HAS_LTO_FLAG)
 | 
				
			||||||
    check_cxx_compiler_flag(-fno-fat-lto-objects CXX_HAS_NO_FAT_LTO_FLAG)
 | 
					    check_cxx_compiler_flag(-fno-fat-lto-objects CXX_HAS_NO_FAT_LTO_FLAG)
 | 
				
			||||||
    if(CXX_HAS_LTO_FLAG)
 | 
					    if(CXX_HAS_LTO_FLAG)
 | 
				
			||||||
      target_compile_options(${target} PUBLIC "$<$<CONFIG:RELEASE>:-flto>")
 | 
					      target_compile_options(${target} PUBLIC "-flto")
 | 
				
			||||||
      set_target_properties(${target} PROPERTIES LINK_FLAGS_RELEASE "-flto")
 | 
					      set_property(TARGET ${target} APPEND PROPERTY LINK_FLAGS "-flto")
 | 
				
			||||||
      if(CXX_HAS_NO_FAT_LTO_FLAG)
 | 
					      if(CXX_HAS_NO_FAT_LTO_FLAG)
 | 
				
			||||||
        target_compile_options(${target} PUBLIC "$<$<CONFIG:RELEASE>:-fno-fat-lto-objects>")
 | 
					        target_compile_options(${target} PUBLIC "-fno-fat-lto-objects")
 | 
				
			||||||
        set_target_properties(${target} PROPERTIES LINK_FLAGS_RELEASE "-fno-fat-lto-objects")
 | 
					        set_property(TARGET ${target} APPEND PROPERTY LINK_FLAGS "-fno-fat-lto-objects")
 | 
				
			||||||
      endif()
 | 
					      endif()
 | 
				
			||||||
    endif()
 | 
					    endif()
 | 
				
			||||||
  endif()
 | 
					  endif()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  set_target_properties(${target} PROPERTIES COTIRE_ENABLE_PRECOMPILED_HEADER
 | 
					  set_property(TARGET ${target} PROPERTY COTIRE_ENABLE_PRECOMPILED_HEADER
 | 
				
			||||||
                                         ${CMLIB_COTIRE_ENABLE_PRECOMPILED_HEADER})
 | 
					                                         ${CMLIB_COTIRE_ENABLE_PRECOMPILED_HEADER})
 | 
				
			||||||
  set_target_properties(${target} PROPERTIES COTIRE_ADD_UNITY_BUILD ${CMLIB_COTIRE_ADD_UNITY_BUILD})
 | 
					  set_property(TARGET ${target} PROPERTY COTIRE_ADD_UNITY_BUILD ${CMLIB_COTIRE_ADD_UNITY_BUILD})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if(CMAKE_BUILD_TYPE STREQUAL Profile)
 | 
					  if(CMAKE_BUILD_TYPE STREQUAL Profile)
 | 
				
			||||||
    target_compile_definitions(${target} ${__visibility} PROFILE)
 | 
					    target_compile_definitions(${target} ${__visibility} PROFILE)
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user