Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix some dependency tracking #6321

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions cmake/SpectreAddInterfaceLibraryHeaders.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,43 @@ function(add_interface_lib_headers)
# elements of a list.
string(REPLACE ";" ":" TARGET_HEADERS
"${ARG_TARGET}=${ARG_HEADERS}")

# BEGIN ADD EXISTING HEADERS
# This block checks if the current target already has a list of header files
# associated with it. If so, then we parse the current headers from the
# string SPECTRE_INTERFACE_LIBRARY_HEADERS. Once we've parsed out the
# _PREVIOUS_HEADERS we append them to the list of current headers,
# (TARGET_HEADERS). Finally, we remove the current target from the interface
# libaries string (SPECTRE_INTERFACE_LIBRARY_HEADERS) because we add it with
# the new headers later.
set(_PREVIOUS_HEADERS "")
string(FIND "${SPECTRE_INTERFACE_LIBRARY_HEADERS}" "${ARG_TARGET}="
_POSITION_OF_TARGET)
if (NOT ${_POSITION_OF_TARGET} EQUAL -1)
string(SUBSTRING "${SPECTRE_INTERFACE_LIBRARY_HEADERS}"
${_POSITION_OF_TARGET} -1 _PREVIOUS_HEADERS)
string(FIND "${_PREVIOUS_HEADERS}" "="
POSITION_OF_THIS_EQUALS)
math(EXPR POSITION_OF_THIS_EQUALS_PLUS_ONE
"${POSITION_OF_THIS_EQUALS} + 1")
string(SUBSTRING "${_PREVIOUS_HEADERS}" ${POSITION_OF_THIS_EQUALS_PLUS_ONE}
-1 _PREVIOUS_HEADERS)
string(FIND "${_PREVIOUS_HEADERS}" "="
POSITION_OF_NEXT_EQUALS)
string(SUBSTRING "${_PREVIOUS_HEADERS}" 0 ${POSITION_OF_NEXT_EQUALS}
_PREVIOUS_HEADERS)
string(FIND "${_PREVIOUS_HEADERS}" ";" POSITION_OF_LAST_SEMI REVERSE)
string(SUBSTRING "${_PREVIOUS_HEADERS}" 0 ${POSITION_OF_LAST_SEMI}
_PREVIOUS_HEADERS)
set(TARGET_HEADERS "${TARGET_HEADERS}:${_PREVIOUS_HEADERS}")
string(REPLACE "${ARG_TARGET}=${_PREVIOUS_HEADERS}" ""
SPECTRE_INTERFACE_LIBRARY_HEADERS "${SPECTRE_INTERFACE_LIBRARY_HEADERS}")
endif()

string(REPLACE ";;" ";"
SPECTRE_INTERFACE_LIBRARY_HEADERS "${SPECTRE_INTERFACE_LIBRARY_HEADERS}")
list(APPEND SPECTRE_INTERFACE_LIBRARY_HEADERS ${TARGET_HEADERS})
# END ADD EXISTING HEADERS

set_property(
GLOBAL PROPERTY SPECTRE_INTERFACE_LIBRARY_HEADERS
Expand Down
1 change: 1 addition & 0 deletions cmake/SpectreCheckDependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ function(check_spectre_libs_dependencies)
ALLOWED_EXTRA_TARGETS
SpectreAllocator
SpectreFlags
SpectrePchFlags
ERROR_ON_FAILURE
)
endforeach(TARGET_TO_CHECK ${ARGN})
Expand Down
23 changes: 16 additions & 7 deletions cmake/SpectreTargetHeaders.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,28 @@ function(spectre_target_headers TARGET_NAME)
ARG "" "INCLUDE_DIRECTORY" "HEADERS"
${ARGN})

if(NOT ARG_INCLUDE_DIRECTORY)
message(FATAL_ERROR
"Must specify the include directory relative to which the "
"header files for a library will be included when calling "
"spectre_target_headers. The named argument is INCLUDE_DIRECTORY.")
endif(NOT ARG_INCLUDE_DIRECTORY)

get_target_property(
TARGET_TYPE
${TARGET_NAME}
TYPE
)

if(NOT ARG_INCLUDE_DIRECTORY)
message(FATAL_ERROR
"Must specify the include directory relative to which the "
"header files for a library will be included when calling "
"spectre_target_headers. The named argument is INCLUDE_DIRECTORY. "
"Call was made for target ${TARGET_NAME}.")
endif(NOT ARG_INCLUDE_DIRECTORY)
# Note: Search the list because an empty HEADERS is okay.
list(FIND ARGN "HEADERS" _FOUND_HEADERS)
if(${_FOUND_HEADERS} EQUAL -1)
message(FATAL_ERROR
"No HEADERS section specified in call to spectre_target_headers "
"for target ${TARGET_NAME}. You must specificy HEADERS before "
"listing the header files.")
endif()

if(NOT ${TARGET_TYPE} STREQUAL INTERFACE_LIBRARY)
get_property(
INCLUDE_DIRS
Expand Down
1 change: 1 addition & 0 deletions src/Evolution/Ringdown/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ spectre_target_sources(
spectre_target_headers(
${LIBRARY}
INCLUDE_DIRECTORY ${CMAKE_SOURCE_DIR}/src
HEADERS
StrahlkorperCoefsInRingdownDistortedFrame.hpp
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
spectre_target_headers(
${LIBRARY}
INCLUDE_DIRECTORY ${CMAKE_SOURCE_DIR}/src
HEADERS
InitialData.hpp
)
Loading