diff --git a/CMakeLists.txt b/CMakeLists.txt index 0d16c69f8e5..8ce6ce4a640 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,12 +13,24 @@ set(UFOAI_PROJECT_UFORADIANT "uforadiant") set(UFOAI_PROJECT_UFOTESTALL "ufotestall") # cmake paths +set(ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR} CACHE STRING "Root dir") +#set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${ROOT_DIR}) set(CMAKE_CONFIG_DIR "${CMAKE_SOURCE_DIR}/cmake/config") set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/cmake/modules ) +if (NOT CMAKE_TOOLCHAIN_FILE) + if (WIN32) + include(${ROOT_DIR}/cmake/toolchains/windows-toolchain.cmake) + elseif (APPLE) + include(${ROOT_DIR}/cmake/toolchains/darwin-toolchain.cmake) + else() + include(${ROOT_DIR}/cmake/toolchains/linux-toolchain.cmake) + endif() +endif() + if(NOT CMAKE_BUILD_TYPE) message(STATUS "CMake build type is not set, defaulting to 'RelWithDebInfo'") set(CMAKE_BUILD_TYPE "RelWithDebInfo") @@ -27,6 +39,7 @@ endif() set(UFOAI_SRC "${CMAKE_SOURCE_DIR}/src") # For some reason, when building against win xp, WINVER and _WIN32_WINNT needs to be defined +# TODO: should go into toolchain file if(WIN32 AND CMAKE_SYSTEM_VERSION) set(win_ver ${CMAKE_SYSTEM_VERSION}) string(REPLACE "." "" win_ver ${win_ver}) @@ -41,6 +54,7 @@ endif() # MSVC2013 conflicts std::min/std::max by including minwindef.h. To avoid that, we can define NOMINMAX if(WIN32 AND MSVC) + # TODO: should go into toolchain file add_definitions(-DNOMINMAX) endif() @@ -104,10 +118,12 @@ message(STATUS "Search path dependencies: ${UFOAI_DEP_SEARCH_PATH}") set(CMAKE_PREFIX_PATH ${UFOAI_DEP_SEARCH_PATH} ${CMAKE_PREFIX_PATH}) ## Packages +find_package(OpenGL) + if(UFOAI_BUILD_UFODED OR UFOAI_BUILD_UFO OR UFOAI_BUILD_UFOTESTALL) - find_package(CURL) + find_package(curl) endif() if(UFOAI_BUILD_UFORADIANT) @@ -119,17 +135,17 @@ if(UFOAI_BUILD_UFO2MAP OR UFOAI_BUILD_UFOMODEL OR UFOAI_BUILD_UFOSLICER OR UFOAI_BUILD_UFOTESTALL) - find_package(JPEG) + find_package(jpeg) endif() if(UFOAI_BUILD_UFO) - find_package(LibIntl) + find_package(intl) endif() if(UFOAI_BUILD_UFO OR UFOAI_BUILD_UFORADIANT OR UFOAI_BUILD_UFOTESTALL) - find_package(OGG) + find_package(ogg) endif() if(UFOAI_BUILD_UFORADIANT) @@ -141,7 +157,7 @@ if(UFOAI_BUILD_UFO2MAP OR UFOAI_BUILD_UFOMODEL OR UFOAI_BUILD_UFOSLICER OR UFOAI_BUILD_UFOTESTALL) - find_package(PNG) + find_package(png) endif() if(UFOAI_BUILD_GAME OR @@ -168,7 +184,8 @@ endif() if(UFOAI_BUILD_UFO OR UFOAI_BUILD_UFORADIANT OR UFOAI_BUILD_UFOTESTALL) - find_package(VORBIS) + find_package(vorbis) + find_package(vorbisfile) endif() if(UFOAI_BUILD_UFO2MAP OR @@ -178,7 +195,7 @@ if(UFOAI_BUILD_UFO2MAP OR UFOAI_BUILD_UFOSLICER OR UFOAI_BUILD_UFORADIANT OR UFOAI_BUILD_UFOTESTALL) - find_package(ZLIB) + find_package(zlib) endif() ############################################################################### @@ -224,6 +241,7 @@ if(UFOAI_BUILD_GAME) ${UFOAI_SRC}/game/inventory.cpp ${UFOAI_SRC}/game/q_shared.cpp + # TODO: support system wide lua installation ${UFOAI_SRC}/libs/lua/lapi.c ${UFOAI_SRC}/libs/lua/lauxlib.c ${UFOAI_SRC}/libs/lua/lbaselib.c @@ -379,6 +397,7 @@ if(UFOAI_BUILD_UFO2MAP) PRIVATE ${ZLIB_INCLUDE_DIRS} ) + # TODO: should be part of the toolchain file if(MINGW) target_link_libraries(${UFOAI_PROJECT_UFO2MAP} mingw32 @@ -393,6 +412,7 @@ if(UFOAI_BUILD_UFO2MAP) ${ZLIB_LIBRARIES} ) + # TODO: should be part of the toolchain file if(WIN32) target_link_libraries(${UFOAI_PROJECT_UFO2MAP} imm32 @@ -508,6 +528,7 @@ if(UFOAI_BUILD_UFODED) endforeach(OUTPUTCONFIG CMAKE_CONFIGURATION_TYPES) # since we embed our manifest, we should not generate a default one + # TODO: should be part of the ufo_add_executable macro if(WIN32 AND MSVC) set_target_properties(${UFOAI_PROJECT_UFODED} PROPERTIES LINK_FLAGS "/MANIFEST:NO") endif() @@ -530,6 +551,7 @@ if(UFOAI_BUILD_UFODED) ${ZLIB_LIBRARIES} ) + # TODO: should be part of the toolchain file if(WIN32) target_link_libraries(${UFOAI_PROJECT_UFODED} imm32 @@ -871,6 +893,7 @@ if(UFOAI_BUILD_UFO) ${UFOAI_SRC}/shared/stringhunk.cpp ${UFOAI_SRC}/shared/utf8.cpp + # TODO: support system wide lua ${UFOAI_SRC}/libs/lua/lapi.c ${UFOAI_SRC}/libs/lua/lauxlib.c ${UFOAI_SRC}/libs/lua/lbaselib.c @@ -963,6 +986,7 @@ if(UFOAI_BUILD_UFO) endforeach(OUTPUTCONFIG CMAKE_CONFIGURATION_TYPES) # since we embed our manifest, we should not generate a default one + # TODO: should be part of the ufo_add_executable macro if(WIN32 AND MSVC) set_target_properties(${UFOAI_PROJECT_UFO} PROPERTIES LINK_FLAGS "/MANIFEST:NO") endif() @@ -982,10 +1006,11 @@ if(UFOAI_BUILD_UFO) PRIVATE ${SDLTTF_INCLUDE_DIR} PRIVATE ${CURL_INCLUDE_DIR} PRIVATE ${VORBIS_INCLUDE_DIR} + PRIVATE ${VORBISFILE_INCLUDE_DIR} PRIVATE ${OGG_INCLUDE_DIR} PRIVATE ${JPEG_INCLUDE_DIR} PRIVATE ${PNG_INCLUDE_DIRS} - PRIVATE ${LIBINTL_INCLUDE_DIR} + PRIVATE ${INTL_INCLUDE_DIR} PRIVATE ${ZLIB_INCLUDE_DIRS} ) @@ -1002,31 +1027,33 @@ if(UFOAI_BUILD_UFO) ${SDL_TTF_LIBRARIES} ${CURL_LIBRARIES} ${VORBIS_LIBRARY} + ${VORBISFILE_LIBRARY} ${OGG_LIBRARIES} ${JPEG_LIBRARIES} ${PNG_LIBRARIES} ${ZLIB_LIBRARIES} ) + # TODO: should be part of the toolchain file if(WIN32 AND MSVC) target_link_libraries(${UFOAI_PROJECT_UFO} - opengl32 - ${LIBINTL_LIBRARIES} + ${OPENGL_LIBRARIES} + ${INTL_LIBRARIES} winmm Ws2_32 ) elseif(WIN32) target_link_libraries(${UFOAI_PROJECT_UFO} - opengl32 + ${OPENGL_LIBRARIES} imm32 - ${LIBINTL_LIBRARIES} + ${INTL_LIBRARIES} version winmm Ws2_32 ) elseif(UNIX) target_link_libraries(${UFOAI_PROJECT_UFO} - GL + ${OPENGL_LIBRARIES} rt ) endif() @@ -1108,6 +1135,7 @@ if(UFOAI_BUILD_UFOMODEL) PRIVATE ${ZLIB_INCLUDE_DIRS} ) + # TODO: should be part of the toolchain file if(MINGW) target_link_libraries(${UFOAI_PROJECT_UFOMODEL} mingw32 @@ -1122,6 +1150,7 @@ if(UFOAI_BUILD_UFOMODEL) ${ZLIB_LIBRARIES} ) + # TODO: should be part of the toolchain file if(WIN32) target_link_libraries(${UFOAI_PROJECT_UFOMODEL} imm32 @@ -1202,6 +1231,7 @@ if(UFOAI_BUILD_UFOSLICER) PRIVATE ${ZLIB_INCLUDE_DIRS} ) + # TODO: should be part of the toolchain file if(MINGW) target_link_libraries(${UFOAI_PROJECT_UFOSLICER} mingw32 @@ -1216,6 +1246,7 @@ if(UFOAI_BUILD_UFOSLICER) ${ZLIB_LIBRARIES} ) + # TODO: should be part of the toolchain file if(WIN32) target_link_libraries(${UFOAI_PROJECT_UFOSLICER} imm32 @@ -1525,6 +1556,7 @@ if(UFOAI_BUILD_UFORADIANT) ${UFOAI_SRC}/tools/radiant/radiant/xyview/XYWnd.cpp ${UFOAI_SRC}/tools/radiant/radiant/xyview/grid/Grid.cpp + # TODO support system wide picomodel ${UFOAI_SRC}/libs/picomodel/picointernal.c ${UFOAI_SRC}/libs/picomodel/picomodel.c ${UFOAI_SRC}/libs/picomodel/picomodules.c @@ -1563,14 +1595,16 @@ if(UFOAI_BUILD_UFORADIANT) PRIVATE ${GTK_INCLUDE_DIRS} PRIVATE ${OPENAL_INCLUDE_DIR} PRIVATE ${VORBIS_INCLUDE_DIR} + PRIVATE ${VORBISFILE_INCLUDE_DIR} PRIVATE ${OGG_INCLUDE_DIR} - PRIVATE ${LIBINTL_INCLUDE_DIR} + PRIVATE ${INTL_INCLUDE_DIR} PRIVATE ${ZLIB_INCLUDE_DIRS} ) target_link_libraries(${UFOAI_PROJECT_UFORADIANT} ${GTK_LIBRARIES} ${VORBIS_LIBRARY_FILE} + ${VORBISFILE_LIBRARY_FILE} ${VORBIS_LIBRARY} ${OGG_LIBRARIES} ${OPENAL_LIBRARIES} @@ -1579,17 +1613,18 @@ if(UFOAI_BUILD_UFORADIANT) ${ZLIB_LIBRARIES} ) + # TODO: should be part of the toolchain file if(WIN32) target_link_libraries(${UFOAI_PROJECT_UFORADIANT} - opengl32 + ${OPENGL_LIBRARIES} imm32 - ${LIBINTL_LIBRARIES} + ${INTL_LIBRARIES} version winmm ) elseif(UNIX) target_link_libraries(${UFOAI_PROJECT_UFORADIANT} - GL + ${OPENGL_LIBRARIES} X11 dl rt @@ -2072,13 +2107,15 @@ if(UFOAI_BUILD_UFOTESTALL) PRIVATE ${SDLTTF_INCLUDE_DIR} PRIVATE ${CURL_INCLUDE_DIR} PRIVATE ${VORBIS_INCLUDE_DIR} + PRIVATE ${VORBISFILE_INCLUDE_DIR} PRIVATE ${OGG_INCLUDE_DIR} PRIVATE ${JPEG_INCLUDE_DIR} PRIVATE ${PNG_INCLUDE_DIRS} - PRIVATE ${LIBINTL_INCLUDE_DIR} + PRIVATE ${INTL_INCLUDE_DIR} PRIVATE ${ZLIB_INCLUDE_DIRS} ) + # TODO: should be part of the toolchain file if(MINGW) target_link_libraries(${UFOAI_PROJECT_UFOTESTALL} mingw32 @@ -2092,24 +2129,26 @@ if(UFOAI_BUILD_UFOTESTALL) ${SDL_TTF_LIBRARIES} ${CURL_LIBRARIES} ${VORBIS_LIBRARY} + ${VORBISFILE_LIBRARY} ${OGG_LIBRARIES} ${JPEG_LIBRARIES} ${PNG_LIBRARIES} ${ZLIB_LIBRARIES} ) + # TODO: should be part of the toolchain file if(WIN32) target_link_libraries(${UFOAI_PROJECT_UFOTESTALL} - opengl32 + ${OPENGL_LIBRARIES} imm32 - ${LIBINTL_LIBRARIES} + ${INTL_LIBRARIES} version winmm Ws2_32 ) elseif(UNIX) target_link_libraries(${UFOAI_PROJECT_UFOTESTALL} - GL + ${OPENGL_LIBRARIES} rt ) endif() diff --git a/cmake/macros.cmake b/cmake/macros.cmake index 40dfbc08fe4..11077ad58ba 100644 --- a/cmake/macros.cmake +++ b/cmake/macros.cmake @@ -75,8 +75,10 @@ endmacro() # Example: ufo_find(SDL2_image SDL_image.h include/SDL2) # macro(ufo_find LIB HEADER SUFFIX) + string(TOUPPER ${LIB} PREFIX_) + STRING(REGEX REPLACE "^LIB" "" PREFIX ${PREFIX_}) + message(STATUS "Checking for ${PREFIX} (${LIB})") if (NOT USE_BUILTIN) - string(TOUPPER ${LIB} PREFIX) if(CMAKE_SIZEOF_VOID_P EQUAL 8) set(_PROCESSOR_ARCH "x64") else() @@ -99,7 +101,6 @@ macro(ufo_find LIB HEADER SUFFIX) set(PKG_PREFIX _${PREFIX}) endif() if (PKG_CONFIG_FOUND) - message(STATUS "Checking for ${LIB}") pkg_check_modules(_${PREFIX} ${LIB}) if (_${PREFIX}_FOUND) set(${PREFIX}_COMPILERFLAGS ${${PKG_PREFIX}_CFLAGS_OTHER}) @@ -137,6 +138,12 @@ macro(ufo_find LIB HEADER SUFFIX) ufo_var_global(${PREFIX}_LIBRARIES) ufo_var_global(${PREFIX}_FOUND) endif() + if (${PREFIX}_FOUND) + message(STATUS "LIBS: ${${PREFIX}_LIBRARIES}") + message(STATUS "INCLUDE_DIRS: ${${PREFIX}_INCLUDE_DIRS}") + else() + message(STATUS "${LIB} not found") + endif() endif() endmacro() diff --git a/cmake/modules/FindCURL.cmake b/cmake/modules/FindCURL.cmake deleted file mode 100644 index 0fb8f45d4fe..00000000000 --- a/cmake/modules/FindCURL.cmake +++ /dev/null @@ -1,61 +0,0 @@ -# - Find curl -# Find the native CURL headers and libraries. -# -# CURL_INCLUDE_DIRS - where to find curl/curl.h, etc. -# CURL_LIBRARIES - List of libraries when using curl. -# CURL_FOUND - True if curl found. -# CURL_VERSION_STRING - the version of curl found (since CMake 2.8.8) - -#============================================================================= -# Copyright 2006-2009 Kitware, Inc. -# Copyright 2012 Rolf Eike Beer -# -# Distributed under the OSI-approved BSD License (the "License"); -# see accompanying file Copyright.txt for details. -# -# This software is distributed WITHOUT ANY WARRANTY; without even the -# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -# See the License for more information. -#============================================================================= -# (To distribute this file outside of CMake, substitute the full -# License text for the above reference.) - -# Look for the header file. -find_path(CURL_INCLUDE_DIR NAMES curl/curl.h) -mark_as_advanced(CURL_INCLUDE_DIR) - -# Look for the library (sorted from most current/relevant entry to least). -find_library(CURL_LIBRARY NAMES - curl - # Windows MSVC prebuilts: - curllib - libcurl_imp - curllib_static - # Windows older "Win32 - MSVC" prebuilts (libcurl.lib, e.g. libcurl-7.15.5-win32-msvc.zip): - libcurl -) -mark_as_advanced(CURL_LIBRARY) - -if(CURL_INCLUDE_DIR) - foreach(_curl_version_header curlver.h curl.h) - if(EXISTS "${CURL_INCLUDE_DIR}/curl/${_curl_version_header}") - file(STRINGS "${CURL_INCLUDE_DIR}/curl/${_curl_version_header}" curl_version_str REGEX "^#define[\t ]+LIBCURL_VERSION[\t ]+\".*\"") - - string(REGEX REPLACE "^#define[\t ]+LIBCURL_VERSION[\t ]+\"([^\"]*)\".*" "\\1" CURL_VERSION_STRING "${curl_version_str}") - unset(curl_version_str) - break() - endif() - endforeach() -endif() - -# handle the QUIETLY and REQUIRED arguments and set CURL_FOUND to TRUE if -# all listed variables are TRUE -include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(CURL - REQUIRED_VARS CURL_LIBRARY CURL_INCLUDE_DIR - VERSION_VAR CURL_VERSION_STRING) - -if(CURL_FOUND) - set(CURL_LIBRARIES ${CURL_LIBRARY}) - set(CURL_INCLUDE_DIRS ${CURL_INCLUDE_DIR}) -endif() diff --git a/cmake/modules/FindJPEG.cmake b/cmake/modules/FindJPEG.cmake deleted file mode 100644 index 8f61742420f..00000000000 --- a/cmake/modules/FindJPEG.cmake +++ /dev/null @@ -1,43 +0,0 @@ -# - Find JPEG -# Find the native JPEG includes and library -# This module defines -# JPEG_INCLUDE_DIR, where to find jpeglib.h, etc. -# JPEG_LIBRARIES, the libraries needed to use JPEG. -# JPEG_FOUND, If false, do not try to use JPEG. -# also defined, but not for general use are -# JPEG_LIBRARY, where to find the JPEG library. - -#============================================================================= -# Copyright 2001-2009 Kitware, Inc. -# -# Distributed under the OSI-approved BSD License (the "License"); -# see accompanying file Copyright.txt for details. -# -# This software is distributed WITHOUT ANY WARRANTY; without even the -# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -# See the License for more information. -#============================================================================= -# (To distribute this file outside of CMake, substitute the full -# License text for the above reference.) - -find_path(JPEG_INCLUDE_DIR jpeglib.h) - -set(JPEG_NAMES ${JPEG_NAMES} jpeg) -find_library(JPEG_LIBRARY NAMES ${JPEG_NAMES} ) - -# handle the QUIETLY and REQUIRED arguments and set JPEG_FOUND to TRUE if -# all listed variables are TRUE -include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(JPEG DEFAULT_MSG JPEG_LIBRARY JPEG_INCLUDE_DIR) - -if(JPEG_FOUND) - set(JPEG_LIBRARIES ${JPEG_LIBRARY}) -endif() - -# Deprecated declarations. -set (NATIVE_JPEG_INCLUDE_PATH ${JPEG_INCLUDE_DIR} ) -if(JPEG_LIBRARY) - get_filename_component (NATIVE_JPEG_LIB_PATH ${JPEG_LIBRARY} PATH) -endif() - -mark_as_advanced(JPEG_LIBRARY JPEG_INCLUDE_DIR) diff --git a/cmake/modules/FindLibIntl.cmake b/cmake/modules/FindLibIntl.cmake deleted file mode 100644 index 28cbe206665..00000000000 --- a/cmake/modules/FindLibIntl.cmake +++ /dev/null @@ -1,22 +0,0 @@ -# Find LIBINTL includes and library -# This module defines -# LIBINTL_INCLUDE_DIR, where to find LIBINTL headers. -# LIBINTL_LIBRARIES, the libraries needed to use LIBINTL. -# LIBINTL_FOUND, If false, do not try to use LIBINTL. -# also defined, but not for general use are -# LIBINTL_LIBRARY, where to find the LIBINTL library. - -find_path(LIBINTL_INCLUDE_DIR libintl.h) - -find_library(LIBINTL_LIBRARY NAMES intl) - -# handle the QUIETLY and REQUIRED arguments and set LIBINTL_FOUND to TRUE if -# all listed variables are TRUE -include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(LIBINTL DEFAULT_MSG LIBINTL_LIBRARY LIBINTL_INCLUDE_DIR) - -if(LIBINTL_FOUND) - set(LIBINTL_LIBRARIES ${LIBINTL_LIBRARY}) -endif() - -mark_as_advanced(LIBINTL_LIBRARY LIBINTL_INCLUDE_DIR) diff --git a/cmake/modules/FindOGG.cmake b/cmake/modules/FindOGG.cmake deleted file mode 100644 index fbb7d5b25eb..00000000000 --- a/cmake/modules/FindOGG.cmake +++ /dev/null @@ -1,22 +0,0 @@ -# Find OGG includes and library -# This module defines -# OGG_INCLUDE_DIR, where to find OGG headers. -# OGG_LIBRARIES, the libraries needed to use OGG. -# OGG_FOUND, If false, do not try to use OGG. -# also defined, but not for general use are -# OGG_LIBRARY, where to find the OGG library. - -find_path(OGG_INCLUDE_DIR ogg/ogg.h) - -find_library(OGG_LIBRARY NAMES ogg) - -# handle the QUIETLY and REQUIRED arguments and set OGG_FOUND to TRUE if -# all listed variables are TRUE -include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(OGG DEFAULT_MSG OGG_LIBRARY OGG_INCLUDE_DIR) - -if(OGG_FOUND) - set(OGG_LIBRARIES ${OGG_LIBRARY}) -endif() - -mark_as_advanced(OGG_LIBRARY OGG_INCLUDE_DIR) diff --git a/cmake/modules/FindPNG.cmake b/cmake/modules/FindPNG.cmake deleted file mode 100644 index a2577d26b01..00000000000 --- a/cmake/modules/FindPNG.cmake +++ /dev/null @@ -1,109 +0,0 @@ -# - Find the native PNG includes and library -# -# This module searches libpng, the library for working with PNG images. -# -# It defines the following variables -# PNG_INCLUDE_DIRS, where to find png.h, etc. -# PNG_LIBRARIES, the libraries to link against to use PNG. -# PNG_DEFINITIONS - You should add_definitons(${PNG_DEFINITIONS}) before compiling code that includes png library files. -# PNG_FOUND, If false, do not try to use PNG. -# PNG_VERSION_STRING - the version of the PNG library found (since CMake 2.8.8) -# Also defined, but not for general use are -# PNG_LIBRARY, where to find the PNG library. -# For backward compatiblity the variable PNG_INCLUDE_DIR is also set. It has the same value as PNG_INCLUDE_DIRS. -# -# Since PNG depends on the ZLib compression library, none of the above will be -# defined unless ZLib can be found. - -#============================================================================= -# Copyright 2002-2009 Kitware, Inc. -# -# Distributed under the OSI-approved BSD License (the "License"); -# see accompanying file Copyright.txt for details. -# -# This software is distributed WITHOUT ANY WARRANTY; without even the -# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -# See the License for more information. -#============================================================================= -# (To distribute this file outside of CMake, substitute the full -# License text for the above reference.) - -if(PNG_FIND_QUIETLY) - set(_FIND_ZLIB_ARG QUIET) -endif() -find_package(ZLIB ${_FIND_ZLIB_ARG}) - -if(ZLIB_FOUND) - find_path(PNG_PNG_INCLUDE_DIR png.h - /usr/local/include/libpng # OpenBSD - ) - - list(APPEND PNG_NAMES png libpng) - unset(PNG_NAMES_DEBUG) - set(_PNG_VERSION_SUFFIXES 17 16 15 14 12) - if (PNG_FIND_VERSION MATCHES "^[0-9]+\\.[0-9]+(\\..*)?$") - string(REGEX REPLACE - "^([0-9]+)\\.([0-9]+).*" "\\1\\2" - _PNG_VERSION_SUFFIX_MIN "${PNG_FIND_VERSION}") - if (PNG_FIND_VERSION_EXACT) - set(_PNG_VERSION_SUFFIXES ${_PNG_VERSION_SUFFIX_MIN}) - else () - string(REGEX REPLACE - "${_PNG_VERSION_SUFFIX_MIN}.*" "${_PNG_VERSION_SUFFIX_MIN}" - _PNG_VERSION_SUFFIXES "${_PNG_VERSION_SUFFIXES}") - endif () - unset(_PNG_VERSION_SUFFIX_MIN) - endif () - foreach(v IN LISTS _PNG_VERSION_SUFFIXES) - list(APPEND PNG_NAMES png${v} libpng${v}) - list(APPEND PNG_NAMES_DEBUG png${v}d libpng${v}d) - endforeach() - unset(_PNG_VERSION_SUFFIXES) - # For compatiblity with versions prior to this multi-config search, honor - # any PNG_LIBRARY that is already specified and skip the search. - if(NOT PNG_LIBRARY) - find_library(PNG_LIBRARY_RELEASE NAMES ${PNG_NAMES}) - find_library(PNG_LIBRARY_DEBUG NAMES ${PNG_NAMES_DEBUG}) - include(${CMAKE_CURRENT_LIST_DIR}/SelectLibraryConfigurations.cmake) - select_library_configurations(PNG) - mark_as_advanced(PNG_LIBRARY_RELEASE PNG_LIBRARY_DEBUG) - endif() - unset(PNG_NAMES) - unset(PNG_NAMES_DEBUG) - - # Set by select_library_configurations(), but we want the one from - # find_package_handle_standard_args() below. - unset(PNG_FOUND) - - if (PNG_LIBRARY AND PNG_PNG_INCLUDE_DIR) - # png.h includes zlib.h. Sigh. - set(PNG_INCLUDE_DIRS ${PNG_PNG_INCLUDE_DIR} ${ZLIB_INCLUDE_DIR} ) - set(PNG_INCLUDE_DIR ${PNG_INCLUDE_DIRS} ) # for backward compatiblity - set(PNG_LIBRARIES ${PNG_LIBRARY} ${ZLIB_LIBRARY}) - - if (CYGWIN) - if(BUILD_SHARED_LIBS) - # No need to define PNG_USE_DLL here, because it's default for Cygwin. - else() - set (PNG_DEFINITIONS -DPNG_STATIC) - endif() - endif () - - endif () - - if (PNG_PNG_INCLUDE_DIR AND EXISTS "${PNG_PNG_INCLUDE_DIR}/png.h") - file(STRINGS "${PNG_PNG_INCLUDE_DIR}/png.h" png_version_str REGEX "^#define[ \t]+PNG_LIBPNG_VER_STRING[ \t]+\".+\"") - - string(REGEX REPLACE "^#define[ \t]+PNG_LIBPNG_VER_STRING[ \t]+\"([^\"]+)\".*" "\\1" PNG_VERSION_STRING "${png_version_str}") - unset(png_version_str) - endif () -endif() - -# handle the QUIETLY and REQUIRED arguments and set PNG_FOUND to TRUE if -# all listed variables are TRUE -include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) -find_package_handle_standard_args(PNG - REQUIRED_VARS PNG_LIBRARY PNG_PNG_INCLUDE_DIR - VERSION_VAR PNG_VERSION_STRING) - -mark_as_advanced(PNG_PNG_INCLUDE_DIR PNG_LIBRARY ) diff --git a/cmake/modules/FindSDL_mixer.cmake b/cmake/modules/FindSDL_mixer.cmake index 6a3b64ed96d..0241ff861a5 100644 --- a/cmake/modules/FindSDL_mixer.cmake +++ b/cmake/modules/FindSDL_mixer.cmake @@ -1,88 +1,2 @@ -# - Locate SDL_mixer library -# This module defines: -# SDL_MIXER_LIBRARIES, the name of the library to link against -# SDL_MIXER_INCLUDE_DIRS, where to find the headers -# SDL_MIXER_FOUND, if false, do not try to link against -# SDL_MIXER_VERSION_STRING - human-readable string containing the version of SDL_mixer -# -# For backward compatiblity the following variables are also set: -# SDLMIXER_LIBRARY (same value as SDL_MIXER_LIBRARIES) -# SDLMIXER_INCLUDE_DIR (same value as SDL_MIXER_INCLUDE_DIRS) -# SDLMIXER_FOUND (same value as SDL_MIXER_FOUND) -# -# $SDLDIR is an environment variable that would -# correspond to the ./configure --prefix=$SDLDIR -# used in building SDL. -# -# Created by Eric Wing. This was influenced by the FindSDL.cmake -# module, but with modifications to recognize OS X frameworks and -# additional Unix paths (FreeBSD, etc). - -#============================================================================= -# Copyright 2005-2009 Kitware, Inc. -# Copyright 2012 Benjamin Eikel -# -# Distributed under the OSI-approved BSD License (the "License"); -# see accompanying file Copyright.txt for details. -# -# This software is distributed WITHOUT ANY WARRANTY; without even the -# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -# See the License for more information. -#============================================================================= -# (To distribute this file outside of CMake, substitute the full -# License text for the above reference.) - -if(NOT SDL_MIXER_INCLUDE_DIR AND SDLMIXER_INCLUDE_DIR) - set(SDL_MIXER_INCLUDE_DIR ${SDLMIXER_INCLUDE_DIR} CACHE PATH "directory cache -entry initialized from old variable name") -endif() -find_path(SDL_MIXER_INCLUDE_DIR SDL_mixer.h - HINTS - ENV SDLMIXERDIR - ENV SDLDIR - PATH_SUFFIXES include/SDL include/SDL12 include/SDL11 include include/SDL2 -) - -if(NOT SDL_MIXER_LIBRARY AND SDLMIXER_LIBRARY) - set(SDL_MIXER_LIBRARY ${SDLMIXER_LIBRARY} CACHE FILEPATH "file cache entry -initialized from old variable name") -endif() -find_library(SDL_MIXER_LIBRARY - NAMES SDL_mixer SDL2_mixer - HINTS - ENV SDLMIXERDIR - ENV SDLDIR - PATH_SUFFIXES lib -) - -if(SDL_MIXER_INCLUDE_DIR AND EXISTS "${SDL_MIXER_INCLUDE_DIR}/SDL_mixer.h") - file(STRINGS "${SDL_MIXER_INCLUDE_DIR}/SDL_mixer.h" SDL_MIXER_VERSION_MAJOR_LINE REGEX "^#define[ \t]+SDL_MIXER_MAJOR_VERSION[ \t]+[0-9]+$") - file(STRINGS "${SDL_MIXER_INCLUDE_DIR}/SDL_mixer.h" SDL_MIXER_VERSION_MINOR_LINE REGEX "^#define[ \t]+SDL_MIXER_MINOR_VERSION[ \t]+[0-9]+$") - file(STRINGS "${SDL_MIXER_INCLUDE_DIR}/SDL_mixer.h" SDL_MIXER_VERSION_PATCH_LINE REGEX "^#define[ \t]+SDL_MIXER_PATCHLEVEL[ \t]+[0-9]+$") - string(REGEX REPLACE "^#define[ \t]+SDL_MIXER_MAJOR_VERSION[ \t]+([0-9]+)$" "\\1" SDL_MIXER_VERSION_MAJOR "${SDL_MIXER_VERSION_MAJOR_LINE}") - string(REGEX REPLACE "^#define[ \t]+SDL_MIXER_MINOR_VERSION[ \t]+([0-9]+)$" "\\1" SDL_MIXER_VERSION_MINOR "${SDL_MIXER_VERSION_MINOR_LINE}") - string(REGEX REPLACE "^#define[ \t]+SDL_MIXER_PATCHLEVEL[ \t]+([0-9]+)$" "\\1" SDL_MIXER_VERSION_PATCH "${SDL_MIXER_VERSION_PATCH_LINE}") - set(SDL_MIXER_VERSION_STRING ${SDL_MIXER_VERSION_MAJOR}.${SDL_MIXER_VERSION_MINOR}.${SDL_MIXER_VERSION_PATCH}) - unset(SDL_MIXER_VERSION_MAJOR_LINE) - unset(SDL_MIXER_VERSION_MINOR_LINE) - unset(SDL_MIXER_VERSION_PATCH_LINE) - unset(SDL_MIXER_VERSION_MAJOR) - unset(SDL_MIXER_VERSION_MINOR) - unset(SDL_MIXER_VERSION_PATCH) -endif() - -set(SDL_MIXER_LIBRARIES ${SDL_MIXER_LIBRARY}) -set(SDL_MIXER_INCLUDE_DIRS ${SDL_MIXER_INCLUDE_DIR}) - -include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) - -FIND_PACKAGE_HANDLE_STANDARD_ARGS(SDL_mixer - REQUIRED_VARS SDL_MIXER_LIBRARIES SDL_MIXER_INCLUDE_DIRS - VERSION_VAR SDL_MIXER_VERSION_STRING) - -# for backward compatiblity -set(SDLMIXER_LIBRARY ${SDL_MIXER_LIBRARIES}) -set(SDLMIXER_INCLUDE_DIR ${SDL_MIXER_INCLUDE_DIRS}) -set(SDLMIXER_FOUND ${SDL_MIXER_FOUND}) - -mark_as_advanced(SDL_MIXER_LIBRARY SDL_MIXER_INCLUDE_DIR) +include(${ROOT_DIR}/cmake/macros.cmake) +ufo_find(SDL_mixer SDL_mixer.h include/SDL) diff --git a/cmake/modules/FindSDL_ttf.cmake b/cmake/modules/FindSDL_ttf.cmake index 6d70ab294d4..dae74fa8410 100644 --- a/cmake/modules/FindSDL_ttf.cmake +++ b/cmake/modules/FindSDL_ttf.cmake @@ -1,88 +1,2 @@ -# - Locate SDL_ttf library -# This module defines: -# SDL_TTF_LIBRARIES, the name of the library to link against -# SDL_TTF_INCLUDE_DIRS, where to find the headers -# SDL_TTF_FOUND, if false, do not try to link against -# SDL_TTF_VERSION_STRING - human-readable string containing the version of SDL_ttf -# -# For backward compatiblity the following variables are also set: -# SDLTTF_LIBRARY (same value as SDL_TTF_LIBRARIES) -# SDLTTF_INCLUDE_DIR (same value as SDL_TTF_INCLUDE_DIRS) -# SDLTTF_FOUND (same value as SDL_TTF_FOUND) -# -# $SDLDIR is an environment variable that would -# correspond to the ./configure --prefix=$SDLDIR -# used in building SDL. -# -# Created by Eric Wing. This was influenced by the FindSDL.cmake -# module, but with modifications to recognize OS X frameworks and -# additional Unix paths (FreeBSD, etc). - -#============================================================================= -# Copyright 2005-2009 Kitware, Inc. -# Copyright 2012 Benjamin Eikel -# -# Distributed under the OSI-approved BSD License (the "License"); -# see accompanying file Copyright.txt for details. -# -# This software is distributed WITHOUT ANY WARRANTY; without even the -# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -# See the License for more information. -#============================================================================= -# (To distribute this file outside of CMake, substitute the full -# License text for the above reference.) - -if(NOT SDL_TTF_INCLUDE_DIR AND SDLTTF_INCLUDE_DIR) - set(SDL_TTF_INCLUDE_DIR ${SDLTTF_INCLUDE_DIR} CACHE PATH "directory cache -entry initialized from old variable name") -endif() -find_path(SDL_TTF_INCLUDE_DIR SDL_ttf.h - HINTS - ENV SDLTTFDIR - ENV SDLDIR - PATH_SUFFIXES include/SDL include/SDL12 include/SDL11 include include/SDL2 -) - -if(NOT SDL_TTF_LIBRARY AND SDLTTF_LIBRARY) - set(SDL_TTF_LIBRARY ${SDLTTF_LIBRARY} CACHE FILEPATH "file cache entry -initialized from old variable name") -endif() -find_library(SDL_TTF_LIBRARY - NAMES SDL_ttf SDL2_ttf - HINTS - ENV SDLTTFDIR - ENV SDLDIR - PATH_SUFFIXES lib -) - -if(SDL_TTF_INCLUDE_DIR AND EXISTS "${SDL_TTF_INCLUDE_DIR}/SDL_ttf.h") - file(STRINGS "${SDL_TTF_INCLUDE_DIR}/SDL_ttf.h" SDL_TTF_VERSION_MAJOR_LINE REGEX "^#define[ \t]+SDL_TTF_MAJOR_VERSION[ \t]+[0-9]+$") - file(STRINGS "${SDL_TTF_INCLUDE_DIR}/SDL_ttf.h" SDL_TTF_VERSION_MINOR_LINE REGEX "^#define[ \t]+SDL_TTF_MINOR_VERSION[ \t]+[0-9]+$") - file(STRINGS "${SDL_TTF_INCLUDE_DIR}/SDL_ttf.h" SDL_TTF_VERSION_PATCH_LINE REGEX "^#define[ \t]+SDL_TTF_PATCHLEVEL[ \t]+[0-9]+$") - string(REGEX REPLACE "^#define[ \t]+SDL_TTF_MAJOR_VERSION[ \t]+([0-9]+)$" "\\1" SDL_TTF_VERSION_MAJOR "${SDL_TTF_VERSION_MAJOR_LINE}") - string(REGEX REPLACE "^#define[ \t]+SDL_TTF_MINOR_VERSION[ \t]+([0-9]+)$" "\\1" SDL_TTF_VERSION_MINOR "${SDL_TTF_VERSION_MINOR_LINE}") - string(REGEX REPLACE "^#define[ \t]+SDL_TTF_PATCHLEVEL[ \t]+([0-9]+)$" "\\1" SDL_TTF_VERSION_PATCH "${SDL_TTF_VERSION_PATCH_LINE}") - set(SDL_TTF_VERSION_STRING ${SDL_TTF_VERSION_MAJOR}.${SDL_TTF_VERSION_MINOR}.${SDL_TTF_VERSION_PATCH}) - unset(SDL_TTF_VERSION_MAJOR_LINE) - unset(SDL_TTF_VERSION_MINOR_LINE) - unset(SDL_TTF_VERSION_PATCH_LINE) - unset(SDL_TTF_VERSION_MAJOR) - unset(SDL_TTF_VERSION_MINOR) - unset(SDL_TTF_VERSION_PATCH) -endif() - -set(SDL_TTF_LIBRARIES ${SDL_TTF_LIBRARY}) -set(SDL_TTF_INCLUDE_DIRS ${SDL_TTF_INCLUDE_DIR}) - -include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) - -FIND_PACKAGE_HANDLE_STANDARD_ARGS(SDL_ttf - REQUIRED_VARS SDL_TTF_LIBRARIES SDL_TTF_INCLUDE_DIRS - VERSION_VAR SDL_TTF_VERSION_STRING) - -# for backward compatiblity -set(SDLTTF_LIBRARY ${SDL_TTF_LIBRARIES}) -set(SDLTTF_INCLUDE_DIR ${SDL_TTF_INCLUDE_DIRS}) -set(SDLTTF_FOUND ${SDL_TTF_FOUND}) - -mark_as_advanced(SDL_TTF_LIBRARY SDL_TTF_INCLUDE_DIR) +include(${ROOT_DIR}/cmake/macros.cmake) +ufo_find(SDL_ttf SDL_ttf.h include/SDL) diff --git a/cmake/modules/FindVORBIS.cmake b/cmake/modules/FindVORBIS.cmake deleted file mode 100644 index 12dad0b1ebf..00000000000 --- a/cmake/modules/FindVORBIS.cmake +++ /dev/null @@ -1,27 +0,0 @@ -# Find VORBIS includes and library -# This module defines -# VORBIS_INCLUDE_DIR, where to find VORBIS headers. -# VORBIS_LIBRARIES, the libraries needed to use VORBIS. -# VORBIS_FOUND, If false, do not try to use VORBIS. -# VORBIS_LIBRARY, where to find the VORBIS library. -# VORBIS_LIBRARY_FILE, where to find the VORBIS file library. - -find_path(VORBIS_INCLUDE_DIR vorbis/vorbisfile.h) - -find_library(VORBIS_LIBRARY NAMES vorbis) - -find_library(VORBIS_LIBRARY_FILE NAMES vorbisfile) - -# handle the QUIETLY and REQUIRED arguments and set VORBIS_FOUND to TRUE if -# all listed variables are TRUE -include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(VORBIS DEFAULT_MSG VORBIS_LIBRARY VORBIS_LIBRARY_FILE) - -if(VORBIS_FOUND) - set(VORBIS_LIBRARIES - ${VORBIS_LIBRARY_FILE} - ${VORBIS_LIBRARY} - ) -endif() - -mark_as_advanced(VORBIS_LIBRARY) diff --git a/cmake/modules/FindZLIB.cmake b/cmake/modules/FindZLIB.cmake deleted file mode 100644 index 00b9c64dac6..00000000000 --- a/cmake/modules/FindZLIB.cmake +++ /dev/null @@ -1,92 +0,0 @@ -# - Find zlib -# Find the native ZLIB includes and library. -# Once done this will define -# -# ZLIB_INCLUDE_DIRS - where to find zlib.h, etc. -# ZLIB_LIBRARIES - List of libraries when using zlib. -# ZLIB_FOUND - True if zlib found. -# -# ZLIB_VERSION_STRING - The version of zlib found (x.y.z) -# ZLIB_VERSION_MAJOR - The major version of zlib -# ZLIB_VERSION_MINOR - The minor version of zlib -# ZLIB_VERSION_PATCH - The patch version of zlib -# ZLIB_VERSION_TWEAK - The tweak version of zlib -# -# The following variable are provided for backward compatibility -# -# ZLIB_MAJOR_VERSION - The major version of zlib -# ZLIB_MINOR_VERSION - The minor version of zlib -# ZLIB_PATCH_VERSION - The patch version of zlib -# -# An includer may set ZLIB_ROOT to a zlib installation root to tell -# this module where to look. - -#============================================================================= -# Copyright 2001-2011 Kitware, Inc. -# -# Distributed under the OSI-approved BSD License (the "License"); -# see accompanying file Copyright.txt for details. -# -# This software is distributed WITHOUT ANY WARRANTY; without even the -# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -# See the License for more information. -#============================================================================= -# (To distribute this file outside of CMake, substitute the full -# License text for the above reference.) - -set(_ZLIB_SEARCHES) - -# Search ZLIB_ROOT first if it is set. -if(ZLIB_ROOT) - set(_ZLIB_SEARCH_ROOT PATHS ${ZLIB_ROOT} NO_DEFAULT_PATH) - list(APPEND _ZLIB_SEARCHES _ZLIB_SEARCH_ROOT) -endif() - -# Normal search. -set(_ZLIB_SEARCH_NORMAL - PATHS "[HKEY_LOCAL_MACHINE\\SOFTWARE\\GnuWin32\\Zlib;InstallPath]" - "$ENV{PROGRAMFILES}/zlib" - ) -list(APPEND _ZLIB_SEARCHES _ZLIB_SEARCH_NORMAL) - -set(ZLIB_NAMES z zlib zdll zlib1 zlibd zlibd1) - -# Try each search configuration. -foreach(search ${_ZLIB_SEARCHES}) - find_path(ZLIB_INCLUDE_DIR NAMES zlib.h ${${search}} PATH_SUFFIXES include) - find_library(ZLIB_LIBRARY NAMES ${ZLIB_NAMES} ${${search}} PATH_SUFFIXES lib) -endforeach() - -mark_as_advanced(ZLIB_LIBRARY ZLIB_INCLUDE_DIR) - -if(ZLIB_INCLUDE_DIR AND EXISTS "${ZLIB_INCLUDE_DIR}/zlib.h") - file(STRINGS "${ZLIB_INCLUDE_DIR}/zlib.h" ZLIB_H REGEX "^#define ZLIB_VERSION \"[^\"]*\"$") - - string(REGEX REPLACE "^.*ZLIB_VERSION \"([0-9]+).*$" "\\1" ZLIB_VERSION_MAJOR "${ZLIB_H}") - string(REGEX REPLACE "^.*ZLIB_VERSION \"[0-9]+\\.([0-9]+).*$" "\\1" ZLIB_VERSION_MINOR "${ZLIB_H}") - string(REGEX REPLACE "^.*ZLIB_VERSION \"[0-9]+\\.[0-9]+\\.([0-9]+).*$" "\\1" ZLIB_VERSION_PATCH "${ZLIB_H}") - set(ZLIB_VERSION_STRING "${ZLIB_VERSION_MAJOR}.${ZLIB_VERSION_MINOR}.${ZLIB_VERSION_PATCH}") - - # only append a TWEAK version if it exists: - set(ZLIB_VERSION_TWEAK "") - if( "${ZLIB_H}" MATCHES "^.*ZLIB_VERSION \"[0-9]+\\.[0-9]+\\.[0-9]+\\.([0-9]+).*$") - set(ZLIB_VERSION_TWEAK "${CMAKE_MATCH_1}") - set(ZLIB_VERSION_STRING "${ZLIB_VERSION_STRING}.${ZLIB_VERSION_TWEAK}") - endif() - - set(ZLIB_MAJOR_VERSION "${ZLIB_VERSION_MAJOR}") - set(ZLIB_MINOR_VERSION "${ZLIB_VERSION_MINOR}") - set(ZLIB_PATCH_VERSION "${ZLIB_VERSION_PATCH}") -endif() - -# handle the QUIETLY and REQUIRED arguments and set ZLIB_FOUND to TRUE if -# all listed variables are TRUE -include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(ZLIB REQUIRED_VARS ZLIB_LIBRARY ZLIB_INCLUDE_DIR - VERSION_VAR ZLIB_VERSION_STRING) - -if(ZLIB_FOUND) - set(ZLIB_INCLUDE_DIRS ${ZLIB_INCLUDE_DIR}) - set(ZLIB_LIBRARIES ${ZLIB_LIBRARY}) -endif() - diff --git a/cmake/modules/Findcurl.cmake b/cmake/modules/Findcurl.cmake new file mode 100644 index 00000000000..28923736567 --- /dev/null +++ b/cmake/modules/Findcurl.cmake @@ -0,0 +1,2 @@ +include(${ROOT_DIR}/cmake/macros.cmake) +ufo_find(libcurl curl.h include/curl) diff --git a/cmake/modules/Findintl.cmake b/cmake/modules/Findintl.cmake new file mode 100644 index 00000000000..79a147fd924 --- /dev/null +++ b/cmake/modules/Findintl.cmake @@ -0,0 +1,2 @@ +include(${ROOT_DIR}/cmake/macros.cmake) +ufo_find(intl libintl.h "") diff --git a/cmake/modules/Findjpeg.cmake b/cmake/modules/Findjpeg.cmake new file mode 100644 index 00000000000..d180c5a028d --- /dev/null +++ b/cmake/modules/Findjpeg.cmake @@ -0,0 +1,2 @@ +include(${ROOT_DIR}/cmake/macros.cmake) +ufo_find(jpeg jpeglib.h "") diff --git a/cmake/modules/Findogg.cmake b/cmake/modules/Findogg.cmake new file mode 100644 index 00000000000..42c4030a66a --- /dev/null +++ b/cmake/modules/Findogg.cmake @@ -0,0 +1,2 @@ +include(${ROOT_DIR}/cmake/macros.cmake) +ufo_find(ogg ogg.h include/ogg) diff --git a/cmake/modules/Findpng.cmake b/cmake/modules/Findpng.cmake new file mode 100644 index 00000000000..23869b8e687 --- /dev/null +++ b/cmake/modules/Findpng.cmake @@ -0,0 +1,2 @@ +include(${ROOT_DIR}/cmake/macros.cmake) +ufo_find(libpng png.h "") diff --git a/cmake/modules/Findvorbis.cmake b/cmake/modules/Findvorbis.cmake new file mode 100644 index 00000000000..6c6e428accd --- /dev/null +++ b/cmake/modules/Findvorbis.cmake @@ -0,0 +1,2 @@ +include(${ROOT_DIR}/cmake/macros.cmake) +ufo_find(vorbis vorbisfile.h include/vorbis) diff --git a/cmake/modules/Findvorbisfile.cmake b/cmake/modules/Findvorbisfile.cmake new file mode 100644 index 00000000000..a5efca7d080 --- /dev/null +++ b/cmake/modules/Findvorbisfile.cmake @@ -0,0 +1,2 @@ +include(${ROOT_DIR}/cmake/macros.cmake) +ufo_find(vorbisfile vorbisfile.h include/vorbis) diff --git a/cmake/modules/Findzlib.cmake b/cmake/modules/Findzlib.cmake new file mode 100644 index 00000000000..6d3bf480b96 --- /dev/null +++ b/cmake/modules/Findzlib.cmake @@ -0,0 +1,2 @@ +include(${ROOT_DIR}/cmake/macros.cmake) +ufo_find(zlib zlib.h "") diff --git a/cmake/toolchains/darwin-toolchain.cmake b/cmake/toolchains/darwin-toolchain.cmake new file mode 100644 index 00000000000..d33e47b22a5 --- /dev/null +++ b/cmake/toolchains/darwin-toolchain.cmake @@ -0,0 +1,21 @@ +set(FRAMEWORKS Foundation IOKit OpenGL Cocoa CoreVideo CoreAudio CoreServices AudioToolbox AudioUnit Carbon ForceFeedback CoreFoundation) + +set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LANGUAGE_STANDARD "c++11") +set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY "libc++") +set(CMAKE_XCODE_ATTRIBUTE_GCC_ENABLE_CPP_EXCEPTIONS "NO") +set(CMAKE_XCODE_ATTRIBUTE_GCC_ENABLE_CPP_RTTI "NO") + +set(CMAKE_C_FLAGS "-fstrict-aliasing -Wno-multichar -Wall -Wextra -Wno-unused-parameter -Wno-unknown-pragmas -Wno-ignored-qualifiers -Wno-long-long -Wno-overloaded-virtual -Wno-unused-volatile-lvalue -Wno-deprecated-writable-strings") +set(CMAKE_C_FLAGS_RELEASE "-O3 -DNDEBUG") +set(CMAKE_C_FLAGS_DEBUG "-O0 -DDEBUG -g") + +set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -std=c++11 -Wnon-virtual-dtor -fno-rtti -fno-exceptions") +set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}") +set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG}") + +set(CMAKE_EXE_LINKER_FLAGS "-ObjC -dead_strip -lpthread") +set(CMAKE_EXE_LINKER_FLAGS_DEBUG "") +set(CMAKE_EXE_LINKER_FLAGS_RELEASE "") +foreach(FW ${FRAMEWORKS}) + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -framework ${FW}") +endforeach() diff --git a/cmake/toolchains/linux-toolchain.cmake b/cmake/toolchains/linux-toolchain.cmake new file mode 100644 index 00000000000..21eac3adba2 --- /dev/null +++ b/cmake/toolchains/linux-toolchain.cmake @@ -0,0 +1,76 @@ +include(CheckFunctionExists) +include(CheckLibraryExists) +include(CheckCCompilerFlag) + +set(CMAKE_THREAD_PREFER_PTHREAD TRUE) +find_package(Threads) + +set(CMAKE_REQUIRED_FLAGS "-Werror -fsanitize=undefined") +check_c_compiler_flag("-faddress-sanitizer" HAVE_FLAG_SANITIZE_UNDEFINED) +set(CMAKE_REQUIRED_FLAGS "-Werror -fsanitize=address") +check_c_compiler_flag("-fsanitize=address" HAVE_FLAG_SANITIZE_ADDRESS) +unset(CMAKE_REQUIRED_FLAGS) + +if (HAVE_FLAG_SANITIZE_UNDEFINED) +set(SANITIZE_FLAGS "${SANITIZE_FLAGS} -fsanitize=undefined") +endif() + +if (HAVE_FLAG_SANITIZE_ADDRESS) +set(SANITIZE_FLAGS "${SANITIZE_FLAGS} -fsanitize=address") +endif() + +set(CMAKE_EXE_LINKER_FLAGS "") +set(CMAKE_EXE_LINKER_FLAGS_RELEASE "") +set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${SANITIZE_FLAGS}") + +if (CMAKE_COMPILER_IS_GNUCXX) + check_function_exists(__atomic_fetch_add_4 HAVE___ATOMIC_FETCH_ADD_4) + if (NOT HAVE___ATOMIC_FETCH_ADD_4) + check_library_exists(atomic __atomic_fetch_add_4 "" HAVE_LIBATOMIC) + if (HAVE_LIBATOMIC) + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -latomic") + endif() + endif() +endif() + +set(CMAKE_C_STANDARD_LIBRARIES ${CMAKE_DL_LIBS}) + +check_include_files(syslog.h HAVE_SYSLOG_H) +check_include_files(execinfo.h HAVE_EXECINFO_H) +set(CURSES_NEED_NCURSES TRUE) +find_package(Curses) +set(HAVE_NCURSES_H ${CURSES_HAVE_NCURSES_H}) +if (HAVE_NCURSES_H) + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}") + set(CMAKE_C_STANDARD_LIBRARIES "${CMAKE_C_STANDARD_LIBRARIES}") +endif() + +check_library_exists(rt clock_gettime "time.h" HAVE_CLOCKGETTIME) +if (HAVE_CLOCKGETTIME) + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lrt") + set(CMAKE_C_STANDARD_LIBRARIES "${CMAKE_C_STANDARD_LIBRARIES} -lrt") +else() + # might also be in libc + check_library_exists(c clock_gettime "" HAVE_CLOCKGETTIME) +endif() + +set(CMAKE_C_FLAGS "-g -Wcast-qual -Wcast-align -Wpointer-arith -Wno-long-long -Wno-multichar -Wshadow -Wall -Wextra -Wno-sign-compare -Wno-unused-parameter -Wreturn-type -Wwrite-strings -Wno-variadic-macros -Wno-unknown-pragmas") +if (CMAKE_USE_PTHREADS_INIT) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pthread") +endif() +set(CMAKE_C_FLAGS_RELEASE "-D_GNU_SOURCE -D_BSD_SOURCE -D_DEFAULT_SOURCE -D_XOPEN_SOURCE -D_FORTIFY_SOURCE=2 -DNDEBUG -fexpensive-optimizations -fomit-frame-pointer -O3") +set(CMAKE_C_FLAGS_DEBUG "-DDEBUG -fno-omit-frame-pointer ${SANITIZE_FLAGS}") + +set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -std=c++11 -Wnon-virtual-dtor -fno-rtti -fno-exceptions") +set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}") +set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG}") + +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}" CACHE STRING "Generic C++ Compiler Flags" FORCE) +set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}" CACHE STRING "C++ Debug Compiler Flags" FORCE) +set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}" CACHE STRING "C++ Release Compiler Flags" FORCE) +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}" CACHE STRING "Generic C Compiler Flags" FORCE) +set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG}" CACHE STRING "C Debug Compiler Flags" FORCE) +set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}" CACHE STRING "C Release Compiler Flags" FORCE) +set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}" CACHE STRING "Generic Linker Flags" FORCE) +set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG}" CACHE STRING "Debug Linker Flags" FORCE) +set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE}" CACHE STRING "Release Linker Flags" FORCE) diff --git a/cmake/toolchains/windows-toolchain.cmake b/cmake/toolchains/windows-toolchain.cmake new file mode 100644 index 00000000000..dd7122c6424 --- /dev/null +++ b/cmake/toolchains/windows-toolchain.cmake @@ -0,0 +1,50 @@ +set(CMAKE_SYSTEM_NAME Windows) + +set(CMAKE_EXE_LINKER_FLAGS "") +set(CMAKE_EXE_LINKER_FLAGS_RELEASE "") +set(CMAKE_EXE_LINKER_FLAGS_DEBUG "") + +if (MSYS) + set(CMAKE_CROSSCOMPILING TRUE) + set(CMAKE_C_FLAGS "-Wcast-qual -Wcast-align -Wpointer-arith -Wshadow -Wall -Wextra -Wreturn-type -Wwrite-strings -Wno-unused-parameter -DWINVER=0x501") + set(CMAKE_C_FLAGS_RELEASE "-O3 -ftree-vectorize -msse3 -ffast-math -DNDEBUG -D_FORTIFY_SOURCE=2") + set(CMAKE_C_FLAGS_DEBUG "-O0 -DDEBUG=1 -ggdb") + + set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -std=c++11 -Wnon-virtual-dtor -fno-rtti -fno-exceptions") + set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}") + set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG}") + + set(CMAKE_EXE_LINKER_FLAGS "-mwindows -static-libgcc -static-libstdc++") + set(CMAKE_C_STANDARD_LIBRARIES "-lmingw32 -lm -ldinput8 -ldxguid -ldxerr8 -luser32 -lgdi32 -lwinmm -limm32 -lole32 -loleaut32 -lshell32 -lversion -luuid -lws2_32 -liphlpapi") + set(CMAKE_CXX_STANDARD_LIBRARIES ${CMAKE_C_STANDARD_LIBRARIES}) +else() + set(CMAKE_C_STANDARD_LIBRARIES "kernel32.lib user32.lib gdi32.lib winspool.lib winmm.lib imm32.lib version.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib dbghelp.lib wsock32.lib ws2_32.lib iphlpapi.lib rpcrt4.lib wininet.lib") + set(CMAKE_CXX_STANDARD_LIBRARIES ${CMAKE_C_STANDARD_LIBRARIES}) + + set(CMAKE_C_FLAGS "/MP /WX /TC /errorReport:queue /DWIN32") + set(CMAKE_C_FLAGS_DEBUG "/Zi /Od /Oy- /MTd /D_DEBUG /DDEBUG=1") + set(CMAKE_C_FLAGS_RELEASE "/Ox /MT /DNDEBUG ") + + set(CMAKE_CXX_FLAGS "/EHsc /MP /WX /TP /DWIN32") + set(CMAKE_CXX_FLAGS_DEBUG "/Zi /Od /Oy- /MTd /D_DEBUG /DDEBUG=1") + set(CMAKE_CXX_FLAGS_RELEASE "/Ox /MT /DNDEBUG") + + if (CMAKE_CL_64) + set(CMAKE_EXE_LINKER_FLAGS "/STACK:5000000 /machine:x64") + else() + set(CMAKE_EXE_LINKER_FLAGS "/STACK:5000000 /machine:x86") + endif() + set(CMAKE_EXE_LINKER_FLAGS_DEBUG "/DEBUG") + set(CMAKE_EXE_LINKER_FLAGS_RELEASE "") +endif() + +set(CMAKE_CONFIGURATION_TYPES "${CMAKE_CONFIGURATION_TYPES}" CACHE STRING "Config Type" FORCE) +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}" CACHE STRING "Generic C++ Compiler Flags" FORCE) +set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}" CACHE STRING "C++ Debug Compiler Flags" FORCE) +set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}" CACHE STRING "C++ Release Compiler Flags" FORCE) +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}" CACHE STRING "Generic C Compiler Flags" FORCE) +set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG}" CACHE STRING "C Debug Compiler Flags" FORCE) +set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}" CACHE STRING "C Release Compiler Flags" FORCE) +set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}" CACHE STRING "Generic Linker Flags" FORCE) +set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG}" CACHE STRING "Debug Linker Flags" FORCE) +set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE}" CACHE STRING "Release Linker Flags" FORCE)