From 92009c3ce5aa005445e5f3a7693d170c455b154c Mon Sep 17 00:00:00 2001 From: kervala Date: Fri, 24 Sep 2010 23:24:05 +0200 Subject: [PATCH] Added: CMake module to find external/3rd party libs --- code/CMakeModules/FindExternal.cmake | 48 ++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 code/CMakeModules/FindExternal.cmake diff --git a/code/CMakeModules/FindExternal.cmake b/code/CMakeModules/FindExternal.cmake new file mode 100644 index 000000000..11489287d --- /dev/null +++ b/code/CMakeModules/FindExternal.cmake @@ -0,0 +1,48 @@ +# Look for a directory containing external libraries. +# +# The following values are defined +# EXTERNAL_INCLUDE_PATH - where to find external includes +# EXTERNAL_LIBRARY_PATH - where to find external libraries +# EXTERNAL_FOUND - True if the external libraries are available + +# also defined, but not for general use are +IF(EXTERNAL_PATH) + # in cache already + SET(EXTERNAL_FIND_QUIETLY TRUE) +ENDIF(EXTERNAL_PATH) + +FIND_PATH(EXTERNAL_PATH + include/png.h + PATHS + ${CMAKE_CURRENT_SOURCE_DIR}/3rdParty + ${CMAKE_CURRENT_SOURCE_DIR}/../3rdParty + ${CMAKE_CURRENT_SOURCE_DIR}/external + ${CMAKE_CURRENT_SOURCE_DIR}/../external +) + +IF(EXTERNAL_PATH) + SET(EXTERNAL_FOUND TRUE) + SET(EXTERNAL_INCLUDE_PATH "${EXTERNAL_PATH}/include") + + # Using 32 or 64 bits libraries + IF(CMAKE_SIZEOF_VOID_P EQUAL 8) + SET(EXTERNAL_LIBRARY_PATH "${EXTERNAL_PATH}/lib64") + ELSE(CMAKE_SIZEOF_VOID_P EQUAL 8) + SET(EXTERNAL_LIBRARY_PATH "${EXTERNAL_PATH}/lib") + ENDIF(CMAKE_SIZEOF_VOID_P EQUAL 8) + + SET(CMAKE_INCLUDE_PATH "${EXTERNAL_INCLUDE_PATH};${CMAKE_INCLUDE_PATH}") + # Stupid hack for FindOpenAL.cmake + SET(CMAKE_INCLUDE_PATH "${EXTERNAL_PATH};${CMAKE_INCLUDE_PATH}") + SET(CMAKE_LIBRARY_PATH "${EXTERNAL_LIBRARY_PATH};${CMAKE_LIBRARY_PATH}") +ENDIF(EXTERNAL_PATH) + +IF(EXTERNAL_FOUND) + IF(NOT EXTERNAL_FIND_QUIETLY) + MESSAGE(STATUS "Found external: ${EXTERNAL_PATH}") + ENDIF(NOT EXTERNAL_FIND_QUIETLY) +ELSE(EXTERNAL_FOUND) + IF(NOT EXTERNAL_FIND_QUIETLY) + MESSAGE(STATUS "Warning: Unable to find external!") + ENDIF(NOT EXTERNAL_FIND_QUIETLY) +ENDIF(EXTERNAL_FOUND)