1 function(link_package NAME)
2 cmake_parse_arguments(LP "ENCOURAGED" "TARGET" "" ${ARGN})
5 string(TOUPPER "${NAME}" UCNAME)
6 add_definitions(-DWITH_${UCNAME})
7 # Some libraries' cmake packages (looking at you, SDL2) leave trailing whitespace in the link commands,
8 # which (later) cmake considers to be an error. Work around this with by stripping the incoming string.
9 if(LP_TARGET AND TARGET ${LP_TARGET})
10 string(STRIP "${LP_TARGET}" LP_TARGET)
11 target_link_libraries(openttd ${LP_TARGET})
12 message(STATUS "${NAME} found -- -DWITH_${UCNAME} -- ${LP_TARGET}")
14 string(STRIP "${${NAME}_LIBRARY}" ${NAME}_LIBRARY)
15 string(STRIP "${${NAME}_LIBRARIES}" ${NAME}_LIBRARIES)
16 include_directories(${${NAME}_INCLUDE_DIRS} ${${NAME}_INCLUDE_DIR})
17 target_link_libraries(openttd ${${NAME}_LIBRARIES} ${${NAME}_LIBRARY})
18 message(STATUS "${NAME} found -- -DWITH_${UCNAME} -- ${${NAME}_INCLUDE_DIRS} ${${NAME}_INCLUDE_DIR} -- ${${NAME}_LIBRARIES} ${${NAME}_LIBRARY}")
21 message(WARNING "${NAME} not found; compiling OpenTTD without ${NAME} is strongly disencouraged")