internaldeps.cmake: Deprecate legacy macros

ADD_INTERFACE_INCLUDEDIR relied on legacy CMake macros such as
INCLUDE_DIRECTORIES. Nowadays, targets do not specify their
dependencies' include directories, but just call target_link_libraries
so that CMake takes care of the rest.

Of course, that requires every target to define their own include
directories, if any, via target_include_directories.


git-svn-id: https://svn.code.sf.net/p/speed-dreams/code/trunk@9591 30fe4595-0a0c-4342-8851-515496e4dcbd

Former-commit-id: f1d7ea3cb16eb1a23d600b219da8c64502e10c00
Former-commit-id: f5f7e5f86e3e984e60f794115da53fb97f7a9b22
This commit is contained in:
xavi92 2024-10-27 07:59:26 +00:00
parent 5798b9b850
commit 2cd6611844
10 changed files with 24 additions and 181 deletions

View file

@ -21,186 +21,10 @@
# SD include dirs macros.
MACRO(ADD_INTERFACE_INCLUDEDIR)
IF(IN_SOURCETREE)
SET(INCLUDE_CANDIDATE ${SOURCE_DIR}/src/interfaces)
ELSE(IN_SOURCETREE)
SET(INCLUDE_CANDIDATE ${SD_INCLUDEDIR_ABS})
ENDIF(IN_SOURCETREE)
FIND_PATH(INTERFACE_INCLUDE_DIR raceman.h
PATHS ${INCLUDE_CANDIDATE} /usr/include /usr/local/include NO_DEFAULT_PATH)
FIND_PATH(INTERFACE_INCLUDE_DIR raceman.h
PATHS ${INCLUDE_CANDIDATE} /usr/include /usr/local/include)
MARK_AS_ADVANCED(INTERFACE_INCLUDE_DIR)
IF(INTERFACE_INCLUDE_DIR)
INCLUDE_DIRECTORIES(${INTERFACE_INCLUDE_DIR})
ELSE(INTERFACE_INCLUDE_DIR)
MESSAGE(FATAL_ERROR "Cannot find interface header files")
ENDIF(INTERFACE_INCLUDE_DIR)
ENDMACRO(ADD_INTERFACE_INCLUDEDIR)
MACRO(ADD_SDLIB_INCLUDEDIR)
SET(SDLIB_OPTIONAL FALSE)
FOREACH(SDLIB_LIB ${ARGN})
IF(${SDLIB_LIB} STREQUAL "OPTIONAL")
SET(SDLIB_OPTIONAL TRUE)
ENDIF(${SDLIB_LIB} STREQUAL "OPTIONAL")
ENDFOREACH(SDLIB_LIB ${ARGN})
FOREACH(SDLIB_LIB ${ARGN})
SET(SDLIB_FOUND_LIB TRUE)
SET(SDLIB_EXTRA_INCLUDEDIR "")
IF(SDLIB_LIB STREQUAL "portability")
IF(IN_SOURCETREE)
SET(INCLUDE_CANDIDATE ${SOURCE_DIR}/src/libs/portability)
ELSE(IN_SOURCETREE)
SET(INCLUDE_CANDIDATE ${SD_INCLUDEDIR_ABS})
ENDIF(IN_SOURCETREE)
FIND_PATH(SDLIB_PORTABILITY_INCLUDE_DIR portability.h PATHS ${INCLUDE_CANDIDATE} /usr/include /usr/local/include NO_DEFAULT_PATH)
FIND_PATH(SDLIB_PORTABILITY_INCLUDE_DIR portability.h PATHS ${INCLUDE_CANDIDATE} /usr/include /usr/local/include)
MARK_AS_ADVANCED(SDLIB_PORTABILITY_INCLUDE_DIR)
SET(SDLIB_EXTRA_INCLUDEDIR SDLIB_PORTABILITY_INCLUDE_DIR)
ELSEIF(SDLIB_LIB STREQUAL "tgf")
IF(IN_SOURCETREE)
SET(INCLUDE_CANDIDATE ${SOURCE_DIR}/src/libs/tgf)
ELSE(IN_SOURCETREE)
SET(INCLUDE_CANDIDATE ${SD_INCLUDEDIR_ABS})
ENDIF(IN_SOURCETREE)
FIND_PATH(SDLIB_TGF_INCLUDE_DIR tgf.h PATHS ${INCLUDE_CANDIDATE} /usr/include /usr/local/include NO_DEFAULT_PATH)
FIND_PATH(SDLIB_TGF_INCLUDE_DIR tgf.h PATHS ${INCLUDE_CANDIDATE} /usr/include /usr/local/include)
MARK_AS_ADVANCED(SDLIB_TGF_INCLUDE_DIR)
SET(SDLIB_EXTRA_INCLUDEDIR SDLIB_TGF_INCLUDE_DIR)
ELSEIF(SDLIB_LIB STREQUAL "tgfclient")
IF(IN_SOURCETREE)
SET(INCLUDE_CANDIDATE ${SOURCE_DIR}/src/libs/tgfclient)
ELSE(IN_SOURCETREE)
SET(INCLUDE_CANDIDATE ${SD_INCLUDEDIR_ABS})
ENDIF(IN_SOURCETREE)
FIND_PATH(SDLIB_TGFCLIENT_INCLUDE_DIR tgfclient.h PATHS ${INCLUDE_CANDIDATE} /usr/include /usr/local/include NO_DEFAULT_PATH)
FIND_PATH(SDLIB_TGFCLIENT_INCLUDE_DIR tgfclient.h PATHS ${INCLUDE_CANDIDATE} /usr/include /usr/local/include)
MARK_AS_ADVANCED(SDLIB_TGFCLIENT_INCLUDE_DIR)
SET(SDLIB_EXTRA_INCLUDEDIR SDLIB_TGFCLIENT_INCLUDE_DIR)
ELSEIF(SDLIB_LIB STREQUAL "tgfdata")
IF(IN_SOURCETREE)
SET(INCLUDE_CANDIDATE ${SOURCE_DIR}/src/libs/tgfdata)
ELSE(IN_SOURCETREE)
SET(INCLUDE_CANDIDATE ${SD_INCLUDEDIR_ABS})
ENDIF(IN_SOURCETREE)
FIND_PATH(SDLIB_TGFDATA_INCLUDE_DIR tgfdata.h PATHS ${INCLUDE_CANDIDATE} /usr/include /usr/local/include NO_DEFAULT_PATH)
FIND_PATH(SDLIB_TGFDATA_INCLUDE_DIR tgfdata.h PATHS ${INCLUDE_CANDIDATE} /usr/include /usr/local/include)
MARK_AS_ADVANCED(SDLIB_TGFDATA_INCLUDE_DIR)
SET(SDLIB_EXTRA_INCLUDEDIR SDLIB_TGFDATA_INCLUDE_DIR)
ELSEIF(SDLIB_LIB STREQUAL "math")
IF(IN_SOURCETREE)
SET(INCLUDE_CANDIDATE ${SOURCE_DIR}/src/libs/math)
ELSE(IN_SOURCETREE)
SET(INCLUDE_CANDIDATE ${SD_INCLUDEDIR_ABS})
ENDIF(IN_SOURCETREE)
FIND_PATH(SDLIB_MATH_INCLUDE_DIR linalg_t.h PATHS ${INCLUDE_CANDIDATE} /usr/include /usr/local/include PATH_SUFFIXES "" math tmath NO_DEFAULT_PATH)
FIND_PATH(SDLIB_MATH_INCLUDE_DIR linalg_t.h PATHS ${INCLUDE_CANDIDATE} /usr/include /usr/local/include PATH_SUFFIXES "" math tmath)
MARK_AS_ADVANCED(SDLIB_MATH_INCLUDE_DIR)
SET(SDLIB_EXTRA_INCLUDEDIR SDLIB_MATH_INCLUDE_DIR)
ELSEIF(SDLIB_LIB STREQUAL "txml")
# Temporary, as TXML will finally get replaced by Expat.
IF(NOT OPTION_3RDPARTY_EXPAT)
IF(IN_SOURCETREE)
SET(INCLUDE_CANDIDATE ${SOURCE_DIR}/src/libs/txml)
ELSE(IN_SOURCETREE)
SET(INCLUDE_CANDIDATE ${SD_INCLUDEDIR_ABS})
ENDIF(IN_SOURCETREE)
FIND_PATH(SDLIB_TXML_INCLUDE_DIR xml.h PATHS ${INCLUDE_CANDIDATE} /usr/include /usr/local/include NO_DEFAULT_PATH)
FIND_PATH(SDLIB_TXML_INCLUDE_DIR xml.h PATHS ${INCLUDE_CANDIDATE} /usr/include /usr/local/include)
MARK_AS_ADVANCED(SDLIB_TXML_INCLUDE_DIR)
SET(SDLIB_EXTRA_INCLUDEDIR SDLIB_TXML_INCLUDE_DIR)
ELSE(NOT OPTION_3RDPARTY_EXPAT)
SET(SDLIB_FOUND_LIB FALSE)
ENDIF(NOT OPTION_3RDPARTY_EXPAT)
ELSEIF(SDLIB_LIB STREQUAL "ephemeris")
IF(IN_SOURCETREE)
SET(INCLUDE_CANDIDATE ${SOURCE_DIR}/src/libs/ephemeris)
ELSE(IN_SOURCETREE)
SET(INCLUDE_CANDIDATE ${SD_INCLUDEDIR_ABS})
ENDIF(IN_SOURCETREE)
FIND_PATH(SDLIB_EPHEMERIS_INCLUDE_DIR ephemeris.h PATHS ${INCLUDE_CANDIDATE} /usr/include /usr/local/include NO_DEFAULT_PATH)
FIND_PATH(SDLIB_EPHEMERIS_INCLUDE_DIR ephemeris.h PATHS ${INCLUDE_CANDIDATE} /usr/include /usr/local/include)
MARK_AS_ADVANCED(SDLIB_EPHEMERIS_INCLUDE_DIR)
SET(SDLIB_EXTRA_INCLUDEDIR SDLIB_EPHEMERIS_INCLUDE_DIR)
ELSEIF(SDLIB_LIB STREQUAL "robottools")
IF(IN_SOURCETREE)
SET(INCLUDE_CANDIDATE ${SOURCE_DIR}/src/libs/robottools)
ELSE(IN_SOURCETREE)
SET(INCLUDE_CANDIDATE ${SD_INCLUDEDIR_ABS})
ENDIF(IN_SOURCETREE)
FIND_PATH(SDLIB_ROBOTTOOLS_INCLUDE_DIR robottools.h PATHS ${INCLUDE_CANDIDATE} /usr/include /usr/local/include NO_DEFAULT_PATH)
FIND_PATH(SDLIB_ROBOTTOOLS_INCLUDE_DIR robottools.h PATHS ${INCLUDE_CANDIDATE} /usr/include /usr/local/include)
MARK_AS_ADVANCED(SDLIB_ROBOTTOOLS_INCLUDE_DIR)
SET(SDLIB_EXTRA_INCLUDEDIR SDLIB_ROBOTTOOLS_INCLUDE_DIR)
ELSEIF(SDLIB_LIB STREQUAL "learning")
IF(IN_SOURCETREE)
SET(INCLUDE_CANDIDATE ${SOURCE_DIR}/src/libs/learning)
ELSE(IN_SOURCETREE)
SET(INCLUDE_CANDIDATE ${SD_INCLUDEDIR_ABS})
ENDIF(IN_SOURCETREE)
FIND_PATH(SDLIB_LEARNING_INCLUDE_DIR learn_debug.h PATHS ${INCLUDE_CANDIDATE} /usr/include /usr/local/include PATH_SUFFIXES "" learning NO_DEFAULT_PATH)
FIND_PATH(SDLIB_LEARNING_INCLUDE_DIR learn_debug.h PATHS ${INCLUDE_CANDIDATE} /usr/include /usr/local/include PATH_SUFFIXES "" learning)
MARK_AS_ADVANCED(SDLIB_LEARNING_INCLUDE_DIR)
SET(SDLIB_EXTRA_INCLUDEDIR SDLIB_LEARNING_INCLUDE_DIR)
ELSEIF(SDLIB_LIB STREQUAL "networking")
IF(IN_SOURCETREE)
SET(INCLUDE_CANDIDATE ${SOURCE_DIR}/src/modules/networking)
ELSE(IN_SOURCETREE)
SET(INCLUDE_CANDIDATE ${SD_INCLUDEDIR_ABS})
ENDIF(IN_SOURCETREE)
FIND_PATH(SDLIB_NETWORKING_INCLUDE_DIR network.h PATHS ${INCLUDE_CANDIDATE} /usr/include /usr/local/include NO_DEFAULT_PATH)
FIND_PATH(SDLIB_NETWORKING_INCLUDE_DIR network.h PATHS ${INCLUDE_CANDIDATE} /usr/include /usr/local/include)
MARK_AS_ADVANCED(SDLIB_NETWORKING_INCLUDE_DIR)
SET(SDLIB_EXTRA_INCLUDEDIR SDLIB_NETWORKING_INCLUDE_DIR)
ELSEIF(SDLIB_LIB STREQUAL "csnetworking")
IF(IN_SOURCETREE)
SET(INCLUDE_CANDIDATE ${SOURCE_DIR}/src/modules/csnetworking)
ELSE(IN_SOURCETREE)
SET(INCLUDE_CANDIDATE ${SD_INCLUDEDIR_ABS})
ENDIF(IN_SOURCETREE)
FIND_PATH(SDLIB_CSNETWORKING_INCLUDE_DIR csnetwork.h PATHS ${INCLUDE_CANDIDATE} /usr/include /usr/local/include NO_DEFAULT_PATH)
FIND_PATH(SDLIB_CSNETWORKING_INCLUDE_DIR csnetwork.h PATHS ${INCLUDE_CANDIDATE} /usr/include /usr/local/include)
MARK_AS_ADVANCED(SDLIB_CSNETWORKING_INCLUDE_DIR)
SET(SDLIB_EXTRA_INCLUDEDIR SDLIB_CSNETWORKING_INCLUDE_DIR)
ELSEIF(SDLIB_LIB STREQUAL "standardgame")
IF(IN_SOURCETREE)
SET(INCLUDE_CANDIDATE ${SOURCE_DIR}/src/modules/racing/standardgame)
ELSE(IN_SOURCETREE)
SET(INCLUDE_CANDIDATE ${SD_INCLUDEDIR_ABS})
ENDIF(IN_SOURCETREE)
FIND_PATH(SDLIB_STANDARDGAME_INCLUDE_DIR standardgame.h PATHS ${INCLUDE_CANDIDATE} /usr/include /usr/local/include NO_DEFAULT_PATH)
FIND_PATH(SDLIB_STANDARDGAME_INCLUDE_DIR standardgame.h PATHS ${INCLUDE_CANDIDATE} /usr/include /usr/local/include)
MARK_AS_ADVANCED(SDLIB_STANDARDGAME_INCLUDE_DIR)
SET(SDLIB_EXTRA_INCLUDEDIR SDLIB_STANDARDGAME_INCLUDE_DIR)
ELSE(SDLIB_LIB STREQUAL "portability")
SET(SDLIB_FOUND_LIB FALSE)
IF(NOT SDLIB_LIB STREQUAL "OPTIONAL")
MESSAGE(WARNING ": ${SDLIB_LIB} is not a Speed Dreams library")
ENDIF(NOT SDLIB_LIB STREQUAL "OPTIONAL")
ENDIF(SDLIB_LIB STREQUAL "portability")
IF(SDLIB_FOUND_LIB)
IF(${SDLIB_EXTRA_INCLUDEDIR})
SET(SDLIB_INCLUDE_DIRS ${SDLIB_INCLUDE_DIRS} ${${SDLIB_EXTRA_INCLUDEDIR}})
ELSE(${SDLIB_EXTRA_INCLUDEDIR})
IF(NOT SDLIB_OPTIONAL AND NOT SDLIB_LIB STREQUAL "OPTIONAL")
MESSAGE(FATAL_ERROR "Cannot find ${SDLIB_LIB} library header files")
ENDIF(NOT SDLIB_OPTIONAL AND NOT SDLIB_LIB STREQUAL "OPTIONAL")
ENDIF(${SDLIB_EXTRA_INCLUDEDIR})
ENDIF(SDLIB_FOUND_LIB)
ENDFOREACH(SDLIB_LIB ${SDLIB_LIBS})
INCLUDE_DIRECTORIES(${SDLIB_INCLUDE_DIRS})
ENDMACRO(ADD_SDLIB_INCLUDEDIR)
# SD libraries macro.
@ -258,5 +82,7 @@ MACRO(ADD_SDLIB_LIBRARY TARGET)
#MESSAGE(STATUS "TARGET_LINK_LIBRARIES(${TARGET} ${SDLIB_LIBRARIES})")
TARGET_LINK_LIBRARIES(${TARGET} ${SDLIB_LIBRARIES})
# FIX: most libraries require this interface library.
TARGET_LINK_LIBRARIES(${TARGET} interfaces)
ENDMACRO(ADD_SDLIB_LIBRARY TARGET)

View file

@ -7,6 +7,9 @@ SET(INTERFACES_HEADERS car.h graphic.h playerpref.h raceman.h
camera.h sound.h)
# Fictive = no-output target, for having source files available in IDEs.
ADD_CUSTOM_TARGET(interfaces SOURCES ${INTERFACES_HEADERS})
SD_ADD_LIBRARY(interfaces INTERFACE ${INTERFACES_HEADERS})
target_include_directories(interfaces INTERFACE ${CMAKE_CURRENT_LIST_DIR})
target_link_libraries(interfaces INTERFACE math)
SD_INSTALL_FILES(INCLUDE FILES ${INTERFACES_HEADERS})

View file

@ -38,7 +38,7 @@ SD_ADD_LIBRARY(ephemeris SHARED ${EPHEMERIS_SOURCES} ${EPHEMERIS_HEADERS})
ADD_PLIB_LIBRARY(ephemeris ul sg)
ADD_SDLIB_LIBRARY(ephemeris portability)
ADD_SDLIB_LIBRARY(ephemeris portability math)
IF(WIN32)
SD_INSTALL_FILES(BIN TARGETS ephemeris)

View file

@ -8,4 +8,5 @@ SET(_SOURCES constants.h linalg_t.h straight2_t.h v2_t.h v3_t.h v4_t.h
SD_INSTALL_FILES(INCLUDE tmath FILES ${_SOURCES})
# Fictive = no-output target, for having source files available in IDEs.
ADD_CUSTOM_TARGET(math SOURCES ${_SOURCES})
add_library(math INTERFACE ${_SOURCES})
target_include_directories(math INTERFACE ${CMAKE_CURRENT_LIST_DIR})

View file

@ -25,7 +25,10 @@ ENDIF(WIN32)
# Note: Headers needed for having them available in IDEs.
SD_ADD_LIBRARY(portability SHARED ${PORTABILITY_SOURCES} ${PORTABILITY_HEADERS})
target_include_directories(portability PRIVATE ${CMAKE_CURRENT_LIST_DIR})
target_include_directories(portability PUBLIC
${CMAKE_BINARY_DIR}
${CMAKE_CURRENT_LIST_DIR}
)
# Might not work with GCC 4.5 or + (non-robot modules crash at 1st reload = after 1 dlclose)
#SET_TARGET_PROPERTIES(portability PROPERTIES VERSION ${VERSION} SOVERSION 0.0.0)

View file

@ -30,6 +30,8 @@ ENDIF(COMMAND CMAKE_POLICY)
# Note: Headers needed for having them available in IDEs.
SD_ADD_LIBRARY(robottools SHARED ${ROBOTTOOLS_SOURCES} ${ROBOTTOOLS_HEADERS})
target_include_directories(robottools PUBLIC ${CMAKE_CURRENT_LIST_DIR})
# Might not work with GCC 4.5 or + (non-robot modules crash at 1st reload = after 1 dlclose)
#SET_TARGET_PROPERTIES(robottools PROPERTIES VERSION ${VERSION} SOVERSION 0.0.0)

View file

@ -35,6 +35,8 @@ ENDIF(WIN32)
# Note: Other sources needed for having them available in IDEs.
SD_ADD_LIBRARY(tgf SHARED ${TGF_HEADERS} ${TGF_SOURCES} ${TGF_OTHER_SOURCES})
target_include_directories(tgf PUBLIC ${CMAKE_CURRENT_LIST_DIR})
# Might not work with GCC 4.5 or + (non-robot modules crash at 1st reload = after 1 dlclose)
#SET_TARGET_PROPERTIES(tgf PROPERTIES VERSION ${VERSION} SOVERSION 0.0.0)

View file

@ -53,6 +53,8 @@ ENDIF(MSVC)
# Note: Other sources needed for having them available in IDEs.
SD_ADD_LIBRARY(tgfclient SHARED ${_SOURCES} ${_OTHER_SOURCES})
target_include_directories(tgfclient PUBLIC ${CMAKE_CURRENT_LIST_DIR})
# Might not work with GCC 4.5 or + (non-robot modules crash at 1st reload = after 1 dlclose)
#SET_TARGET_PROPERTIES(tgfclient PROPERTIES VERSION ${VERSION} SOVERSION 0.0.0)
@ -64,7 +66,7 @@ ADD_SDLIB_LIBRARY(tgfclient portability tgf)
ADD_PNG_LIBRARY(tgfclient)
ADD_JPEG_LIBRARY(tgfclient)
IF(OPTION_WEBSERVER)
ADD_CURL_LIBRARY(tgfclient)
target_link_libraries(tgfclient CURL::libcurl)
ENDIF(OPTION_WEBSERVER)
IF(OPENGL_FOUND)

View file

@ -37,6 +37,8 @@ ENDIF(CMAKE_SKIP_RPATH OR CMAKE_SKIP_BUILD_RPATH)
ADD_SDLIB_LIBRARY(tgfdata portability txml tgf) # txml ignored if OPTION_3RDPARTY_EXPAT
target_include_directories(tgfdata PUBLIC ${CMAKE_CURRENT_LIST_DIR})
ADD_PLIB_LIBRARY(tgfdata sg ul)
IF(WIN32)

View file

@ -14,6 +14,8 @@ endif(COMMAND cmake_policy)
#TODO: Maje this a real (dynamically loadable) module, or move it to standard src/libs !
SD_ADD_LIBRARY(csnetworking SHARED ${SD_CSNETWORK_SOURCES} ${SD_CSNETWORK_HEADERS})
target_include_directories(csnetworking PUBLIC ${CMAKE_CURRENT_LIST_DIR})
# Might not work with GCC 4.5 or + (non-robot modules crash at 1st reload = after 1 dlclose)
#SET_TARGET_PROPERTIES(csnetworking PROPERTIES VERSION ${VERSION} SOVERSION 0.0.0)