mirror of https://github.com/OpenTTD/OpenTTD
Fix: Work around cmake bug by stripping link target strings
parent
53f36f4afa
commit
a0307652f3
|
@ -4,10 +4,15 @@ function(link_package NAME)
|
||||||
if(${NAME}_FOUND)
|
if(${NAME}_FOUND)
|
||||||
string(TOUPPER "${NAME}" UCNAME)
|
string(TOUPPER "${NAME}" UCNAME)
|
||||||
add_definitions(-DWITH_${UCNAME})
|
add_definitions(-DWITH_${UCNAME})
|
||||||
|
# Some libraries' cmake packages (looking at you, SDL2) leave trailing whitespace in the link commands,
|
||||||
|
# which (later) cmake considers to be an error. Work around this with by stripping the incoming string.
|
||||||
if(LP_TARGET AND TARGET ${LP_TARGET})
|
if(LP_TARGET AND TARGET ${LP_TARGET})
|
||||||
|
string(STRIP "${LP_TARGET}" LP_TARGET)
|
||||||
target_link_libraries(openttd ${LP_TARGET})
|
target_link_libraries(openttd ${LP_TARGET})
|
||||||
message(STATUS "${NAME} found -- -DWITH_${UCNAME} -- ${LP_TARGET}")
|
message(STATUS "${NAME} found -- -DWITH_${UCNAME} -- ${LP_TARGET}")
|
||||||
else()
|
else()
|
||||||
|
string(STRIP "${${NAME}_LIBRARY}" ${NAME}_LIBRARY)
|
||||||
|
string(STRIP "${${NAME}_LIBRARIES}" ${NAME}_LIBRARIES)
|
||||||
include_directories(${${NAME}_INCLUDE_DIRS} ${${NAME}_INCLUDE_DIR})
|
include_directories(${${NAME}_INCLUDE_DIRS} ${${NAME}_INCLUDE_DIR})
|
||||||
target_link_libraries(openttd ${${NAME}_LIBRARIES} ${${NAME}_LIBRARY})
|
target_link_libraries(openttd ${${NAME}_LIBRARIES} ${${NAME}_LIBRARY})
|
||||||
message(STATUS "${NAME} found -- -DWITH_${UCNAME} -- ${${NAME}_INCLUDE_DIRS} ${${NAME}_INCLUDE_DIR} -- ${${NAME}_LIBRARIES} ${${NAME}_LIBRARY}")
|
message(STATUS "${NAME} found -- -DWITH_${UCNAME} -- ${${NAME}_INCLUDE_DIRS} ${${NAME}_INCLUDE_DIR} -- ${${NAME}_LIBRARIES} ${${NAME}_LIBRARY}")
|
||||||
|
|
Loading…
Reference in New Issue