athena/atdna/atdnaConfig.cmake.in

85 lines
3.1 KiB
CMake
Raw Normal View History

2015-08-03 01:42:47 +00:00
# - Config file for the atdna package
# Compute paths
2017-12-07 04:07:33 +00:00
get_filename_component(ATDNA_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
2015-08-03 01:42:47 +00:00
# Our library dependencies (contains definitions for IMPORTED targets)
if(NOT TARGET atdna AND NOT atdna_BINARY_DIR)
2017-12-07 04:07:33 +00:00
include("${ATDNA_CMAKE_DIR}/atdnaTargets.cmake")
2015-08-03 01:42:47 +00:00
endif()
# Super handy macro for adding atdna target
2018-10-07 02:51:06 +00:00
function(atdna out)
# Ninja wants invocations in root binary dir for DEPFILE application
file(RELATIVE_PATH out_rel ${CMAKE_BINARY_DIR} "${CMAKE_CURRENT_BINARY_DIR}/${out}")
2015-08-03 01:42:47 +00:00
# Make input files source-relative
set(ins "")
set(ins_impdeps "")
2015-08-03 01:42:47 +00:00
foreach(arg ${ARGN})
list(APPEND ins ${CMAKE_CURRENT_SOURCE_DIR}/${arg})
list(APPEND ins_impdeps CXX)
list(APPEND ins_impdeps ${CMAKE_CURRENT_SOURCE_DIR}/${arg})
2015-08-03 01:42:47 +00:00
endforeach()
# Get local include directories for atdna
get_property(incdirs DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY INCLUDE_DIRECTORIES)
set(inccli "")
foreach(dir ${incdirs})
list(APPEND inccli "-I${dir}")
endforeach()
# Get local defines for atdna
get_property(cdefs DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY COMPILE_DEFINITIONS)
set(cdefcli "")
foreach(def ${cdefs})
list(APPEND cdefcli "-D${def}")
endforeach()
# MS extra
unset(extraargs)
if(MSVC)
list(APPEND extraargs -fms-compatibility -fexceptions)
if(MSVC_VERSION EQUAL 1800)
list(APPEND extraargs -fms-compatibility-version=18.00)
elseif(MSVC_VERSION EQUAL 1900)
list(APPEND extraargs -fms-compatibility-version=19.00)
elseif(MSVC_VERSION EQUAL 1910)
list(APPEND extraargs -fms-compatibility-version=19.10)
2017-10-24 03:10:58 +00:00
elseif(MSVC_VERSION EQUAL 1911)
list(APPEND extraargs -fms-compatibility-version=19.11)
endif()
# OSX Extra
elseif(APPLE)
get_filename_component(COMPILER_DIR "${CMAKE_CXX_COMPILER}" DIRECTORY)
if (NOT EXISTS "${CMAKE_OSX_SYSROOT}")
message(FATAL_ERROR "CMAKE_OSX_SYSROOT not set")
endif()
list(APPEND extraargs
2018-08-28 03:47:14 +00:00
-I ${COMPILER_DIR}/../include/c++/v1
-isysroot ${CMAKE_OSX_SYSROOT})
2015-08-03 01:42:47 +00:00
endif()
2015-08-03 01:42:47 +00:00
# Make target
if(${CMAKE_GENERATOR} STREQUAL "Ninja")
# Use Ninja's DEPFILE parser in cooperation with atdna
add_custom_command(OUTPUT ${out} COMMAND $<TARGET_FILE:atdna>
ARGS ${extraargs} -o ${out_rel} -MD -MT ${out_rel} -MF ${out_rel}.d ${cdefcli} ${inccli}
"-I${ATHENA_INCLUDE_DIR}" ${ins}
DEPENDS atdna ${ins} IMPLICIT_DEPENDS ${ins_impdeps}
DEPFILE "${CMAKE_CURRENT_BINARY_DIR}/${out}.d"
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
COMMENT "Generating DNA ${out_rel}")
else()
# Use CMake's built-in dependency scanner for makefile targets
add_custom_command(OUTPUT ${out} COMMAND $<TARGET_FILE:atdna>
ARGS ${extraargs} -o ${out_rel} ${cdefcli} ${inccli}
"-I${ATHENA_INCLUDE_DIR}" ${ins}
DEPENDS atdna ${ins} IMPLICIT_DEPENDS ${ins_impdeps}
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
COMMENT "Generating DNA ${out_rel}")
endif()
2018-10-07 02:51:06 +00:00
endfunction()
2015-08-03 01:42:47 +00:00