2015-08-03 01:42:47 +00:00
|
|
|
# - Config file for the atdna package
|
2022-08-03 22:16:30 +00:00
|
|
|
|
2015-08-03 01:42:47 +00:00
|
|
|
# Compute paths
|
2017-12-07 04:07:33 +00:00
|
|
|
get_filename_component(ATDNA_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
|
2022-08-03 22:16:30 +00:00
|
|
|
|
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)
|
2017-08-20 05:22:25 +00:00
|
|
|
# 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 "")
|
2017-08-20 05:22:25 +00:00
|
|
|
set(ins_impdeps "")
|
2015-08-03 01:42:47 +00:00
|
|
|
foreach(arg ${ARGN})
|
|
|
|
list(APPEND ins ${CMAKE_CURRENT_SOURCE_DIR}/${arg})
|
2017-08-20 05:22:25 +00:00
|
|
|
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})
|
2022-08-03 22:16:30 +00:00
|
|
|
if (NOT dir MATCHES ".*emscripten.*")
|
|
|
|
list(APPEND inccli "-I${dir}")
|
|
|
|
endif()
|
2015-08-03 01:42:47 +00:00
|
|
|
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)
|
2017-08-25 06:17:03 +00: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)
|
2017-08-25 06:17:03 +00:00
|
|
|
endif()
|
2015-09-02 18:49:23 +00:00
|
|
|
|
|
|
|
# OSX Extra
|
|
|
|
elseif(APPLE)
|
2018-01-03 23:52:01 +00:00
|
|
|
get_filename_component(COMPILER_DIR "${CMAKE_CXX_COMPILER}" DIRECTORY)
|
2017-08-25 06:17:03 +00:00
|
|
|
if (NOT EXISTS "${CMAKE_OSX_SYSROOT}")
|
|
|
|
message(FATAL_ERROR "CMAKE_OSX_SYSROOT not set")
|
|
|
|
endif()
|
2021-04-08 20:18:20 +00:00
|
|
|
file(GLOB SYSTEM_INCLUDE_DIR "${COMPILER_DIR}/../lib/clang/*/include")
|
2018-01-03 23:52:01 +00:00
|
|
|
list(APPEND extraargs
|
2021-01-07 01:30:40 +00:00
|
|
|
-isysroot ${CMAKE_OSX_SYSROOT}
|
2021-04-08 20:18:20 +00:00
|
|
|
-stdlib++-isystem "${COMPILER_DIR}/../include/c++/v1"
|
|
|
|
-isystem "${SYSTEM_INCLUDE_DIR}")
|
2015-08-03 01:42:47 +00:00
|
|
|
endif()
|
2015-09-02 18:49:23 +00:00
|
|
|
|
2015-08-03 01:42:47 +00:00
|
|
|
# Make target
|
2017-08-20 05:22:25 +00:00
|
|
|
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}
|
2020-09-28 20:48:27 +00:00
|
|
|
"-I${ATHENA_INCLUDE_DIR}" ${ins}
|
2017-08-20 05:22:25 +00:00
|
|
|
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}
|
2020-09-28 20:48:27 +00:00
|
|
|
"-I${ATHENA_INCLUDE_DIR}" ${ins}
|
2017-08-20 05:22:25 +00:00
|
|
|
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
|
|
|
|