diff --git a/CMakeLists.txt b/CMakeLists.txt index 0f1be940a5..edac6b4c5d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -28,6 +28,7 @@ set(TORQUE_SOURCE_DIRECTROY "${CMAKE_SOURCE_DIR}/Engine/source") # Ensure all possible configurations end up in the project directory set(CMAKE_INSTALL_PREFIX "${TORQUE_APP_ROOT_DIRECTORY}" CACHE STRING "" FORCE) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${TORQUE_APP_GAME_DIRECTORY}") +set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/Tools/CMake/finders") foreach( OUTPUTCONFIG ${CMAKE_CONFIGURATION_TYPES} ) string( TOUPPER ${OUTPUTCONFIG} OUTPUTCONFIG ) set( CMAKE_RUNTIME_OUTPUT_DIRECTORY_${OUTPUTCONFIG} "${TORQUE_APP_GAME_DIRECTORY}" ) diff --git a/Engine/lib/CMakeLists.txt b/Engine/lib/CMakeLists.txt index 56b36873a4..1000cba536 100644 --- a/Engine/lib/CMakeLists.txt +++ b/Engine/lib/CMakeLists.txt @@ -6,8 +6,6 @@ set(ZLIB_ROOT "${ZLIB_ROOT}" CACHE STRING "ZLib root location" FORCE) mark_as_advanced(ZLIB_ROOT) # Png depends on zlib add_subdirectory(zlib ${TORQUE_LIB_TARG_DIRECTORY}/zlib EXCLUDE_FROM_ALL) -set(ZLIB_FOUND 1) -set(ZLIB_LIBRARIES zlib) if(APPLE) enable_language(OBJC) diff --git a/Tools/CMake/finders/findFLAC.cmake b/Tools/CMake/finders/findFLAC.cmake new file mode 100644 index 0000000000..a77e4901bf --- /dev/null +++ b/Tools/CMake/finders/findFLAC.cmake @@ -0,0 +1,13 @@ +if(TARGET FLAC) + set(FLAC_FOUND TRUE) + set(FLAC_INCLUDE_DIRS $) + set(FLAC_LIBRARIES FLAC) + + # Provide an alias for consistency with modern CMake + if(NOT TARGET FLAC::FLAC) + add_library(FLAC::FLAC ALIAS FLAC) + endif() +else() + set(FLAC_FOUND FALSE) + message(FATAL_ERROR "Flac was not added with add_subdirectory before calling find_package(FLAC).") +endif() \ No newline at end of file diff --git a/Tools/CMake/finders/findOGG.cmake b/Tools/CMake/finders/findOGG.cmake new file mode 100644 index 0000000000..3cdb22111c --- /dev/null +++ b/Tools/CMake/finders/findOGG.cmake @@ -0,0 +1,13 @@ +if(TARGET ogg) + set(OGG_FOUND TRUE) + set(OGG_INCLUDE_DIRS $) + set(OGG_LIBRARIES ogg) + + # Provide an alias for consistency with modern CMake + if(NOT TARGET OGG::OGG) + add_library(OGG::OGG ALIAS ogg) + endif() +else() + set(OGG_FOUND FALSE) + message(FATAL_ERROR "Ogg was not added with add_subdirectory before calling find_package(Ogg).") +endif() \ No newline at end of file diff --git a/Tools/CMake/finders/findOPUS.cmake b/Tools/CMake/finders/findOPUS.cmake new file mode 100644 index 0000000000..0ed268a3d3 --- /dev/null +++ b/Tools/CMake/finders/findOPUS.cmake @@ -0,0 +1,13 @@ +if(TARGET opus) + set(OPUS_FOUND TRUE) + set(OPUS_INCLUDE_DIRS $) + set(OPUS_LIBRARIES opus) + + # Provide an alias for consistency with modern CMake + if(NOT TARGET OPUS::OPUS) + add_library(OPUS::OPUS ALIAS opus) + endif() +else() + set(OPUS_FOUND FALSE) + message(FATAL_ERROR "Opus was not added with add_subdirectory before calling find_package(Opus).") +endif() \ No newline at end of file diff --git a/Tools/CMake/finders/findPCRE.cmake b/Tools/CMake/finders/findPCRE.cmake new file mode 100644 index 0000000000..9db8c09f00 --- /dev/null +++ b/Tools/CMake/finders/findPCRE.cmake @@ -0,0 +1,13 @@ +if(TARGET pcre) + set(PCRE_FOUND TRUE) + set(PCRE_INCLUDE_DIRS $) + set(PCRE_LIBRARIES pcre) + + # Provide an alias for consistency with modern CMake + if(NOT TARGET PCRE::PCRE) + add_library(PCRE::PCRE ALIAS pcre) + endif() +else() + set(PCRE_FOUND FALSE) + message(FATAL_ERROR "PCRE was not added with add_subdirectory before calling find_package(PCRE).") +endif() \ No newline at end of file diff --git a/Tools/CMake/finders/findVorbis.cmake b/Tools/CMake/finders/findVorbis.cmake new file mode 100644 index 0000000000..4fd196bf32 --- /dev/null +++ b/Tools/CMake/finders/findVorbis.cmake @@ -0,0 +1,13 @@ +if(TARGET vorbis) + set(VORBIS_FOUND TRUE) + set(VORBIS_INCLUDE_DIRS $) + set(VORBIS_LIBRARIES vorbis) + + # Provide an alias for consistency with modern CMake + if(NOT TARGET VORBIS::VORBIS) + add_library(VORBIS::VORBIS ALIAS vorbis) + endif() +else() + set(VORBIS_FOUND FALSE) + message(FATAL_ERROR "Vorbis was not added with add_subdirectory before calling find_package(Vorbis).") +endif() \ No newline at end of file diff --git a/Tools/CMake/finders/findZlib.cmake b/Tools/CMake/finders/findZlib.cmake new file mode 100644 index 0000000000..b3a4999e96 --- /dev/null +++ b/Tools/CMake/finders/findZlib.cmake @@ -0,0 +1,14 @@ +# Ensure zlib has been added before using this module +if(TARGET zlib) + set(ZLIB_FOUND TRUE) + set(ZLIB_INCLUDE_DIRS $) + set(ZLIB_LIBRARIES zlib) + message(STATUS "Using Torques build of zlib.") + # Provide an alias for consistency with modern CMake + if(NOT TARGET ZLIB::ZLIB) + add_library(ZLIB::ZLIB ALIAS zlib) + endif() +else() + set(ZLIB_FOUND FALSE) + message(FATAL_ERROR "Zlib was not added with add_subdirectory before calling find_package(ZLIB).") +endif() \ No newline at end of file