mirror of
https://github.com/JGRennison/OpenTTD-patches.git
synced 2024-11-04 06:00:15 +00:00
56d54cf60e
CMake works on all our supported platforms, like MSVC, Mingw, GCC, Clang, and many more. It allows for a single way of doing things, so no longer we need shell scripts and vbs scripts to work on all our supported platforms. Additionally, CMake allows to generate project files for like MSVC, KDevelop, etc. This heavily reduces the lines of code we need to support multiple platforms from a project perspective. Addtiionally, this heavily improves our detection of libraries, etc.
19 lines
891 B
CMake
19 lines
891 B
CMake
function(link_package NAME)
|
|
cmake_parse_arguments(LP "ENCOURAGED" "TARGET" "" ${ARGN})
|
|
|
|
if (${NAME}_FOUND)
|
|
string(TOUPPER "${NAME}" UCNAME)
|
|
add_definitions(-DWITH_${UCNAME})
|
|
if (LP_TARGET AND TARGET ${LP_TARGET})
|
|
target_link_libraries(openttd ${LP_TARGET})
|
|
message(STATUS "${NAME} found -- -DWITH_${UCNAME} -- ${LP_TARGET}")
|
|
else()
|
|
include_directories(${${NAME}_INCLUDE_DIRS} ${${NAME}_INCLUDE_DIR})
|
|
target_link_libraries(openttd ${${NAME}_LIBRARIES} ${${NAME}_LIBRARY})
|
|
message(STATUS "${NAME} found -- -DWITH_${UCNAME} -- ${${NAME}_INCLUDE_DIRS} ${${NAME}_INCLUDE_DIR} -- ${${NAME}_LIBRARIES} ${${NAME}_LIBRARY}")
|
|
endif()
|
|
elseif (LP_ENCOURAGED)
|
|
message(WARNING "${NAME} not found; compiling OpenTTD without ${NAME} is strongly disencouraged")
|
|
endif()
|
|
endfunction()
|