Add: introduce CMake for project management
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.
2019-04-07 09:57:55 +00:00
|
|
|
function(link_package NAME)
|
|
|
|
cmake_parse_arguments(LP "ENCOURAGED" "TARGET" "" ${ARGN})
|
|
|
|
|
2020-09-25 11:55:25 +00:00
|
|
|
if(${NAME}_FOUND)
|
Add: introduce CMake for project management
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.
2019-04-07 09:57:55 +00:00
|
|
|
string(TOUPPER "${NAME}" UCNAME)
|
|
|
|
add_definitions(-DWITH_${UCNAME})
|
2020-09-25 21:41:34 +00:00
|
|
|
# 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.
|
2020-09-25 11:55:25 +00:00
|
|
|
if(LP_TARGET AND TARGET ${LP_TARGET})
|
2020-09-25 21:41:34 +00:00
|
|
|
string(STRIP "${LP_TARGET}" LP_TARGET)
|
Add: introduce CMake for project management
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.
2019-04-07 09:57:55 +00:00
|
|
|
target_link_libraries(openttd ${LP_TARGET})
|
|
|
|
message(STATUS "${NAME} found -- -DWITH_${UCNAME} -- ${LP_TARGET}")
|
|
|
|
else()
|
2020-09-25 21:41:34 +00:00
|
|
|
string(STRIP "${${NAME}_LIBRARY}" ${NAME}_LIBRARY)
|
|
|
|
string(STRIP "${${NAME}_LIBRARIES}" ${NAME}_LIBRARIES)
|
Add: introduce CMake for project management
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.
2019-04-07 09:57:55 +00:00
|
|
|
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()
|
2020-09-25 11:55:25 +00:00
|
|
|
elseif(LP_ENCOURAGED)
|
Add: introduce CMake for project management
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.
2019-04-07 09:57:55 +00:00
|
|
|
message(WARNING "${NAME} not found; compiling OpenTTD without ${NAME} is strongly disencouraged")
|
|
|
|
endif()
|
|
|
|
endfunction()
|