mirror of
https://github.com/CorsixTH/CorsixTH.git
synced 2025-07-23 20:30:35 +02:00
Consistent style for CMake scripts
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
# Project Declaration
|
||||
PROJECT(AnimView)
|
||||
project(AnimView)
|
||||
|
||||
# Generate source files list
|
||||
# Note: do not use generic includes (*.cpp and such) this will break things with cmake
|
||||
SET(animview_source_files
|
||||
set(animview_source_files
|
||||
app.cpp
|
||||
frmMain.cpp
|
||||
frmSprites.cpp
|
||||
@@ -24,8 +24,7 @@ SET(animview_source_files
|
||||
)
|
||||
|
||||
# Declaration of the executable
|
||||
IF(APPLE)
|
||||
|
||||
if(APPLE)
|
||||
set(corsixth_icon_file ${CMAKE_SOURCE_DIR}/AnimView/Icon.icns)
|
||||
set_source_files_properties(
|
||||
${corsixth_icon_file}
|
||||
@@ -43,57 +42,56 @@ IF(APPLE)
|
||||
|
||||
set_target_properties(AnimView PROPERTIES LINK_FLAGS_MINSIZEREL "-dead_strip")
|
||||
set_target_properties(AnimView PROPERTIES XCODE_ATTRIBUTE_LD_RUNPATH_SEARCH_PATHS "@executable_path/../Frameworks")
|
||||
|
||||
ELSE()
|
||||
else()
|
||||
add_executable(
|
||||
AnimView
|
||||
WIN32 # This prevents the dos console showing up
|
||||
${animview_source_files}
|
||||
)
|
||||
ENDIF()
|
||||
endif()
|
||||
|
||||
# Finding libraries
|
||||
## Finding libraries
|
||||
|
||||
# Find WxWidgets
|
||||
SET(wxWidgets_USE_LIBS core base) # optionally: more than wx std libs
|
||||
FIND_PACKAGE(wxWidgets REQUIRED)
|
||||
IF(wxWidgets_FOUND)
|
||||
LINK_LIBRARIES(${wxWidgets_LIBRARIES})
|
||||
INCLUDE_DIRECTORIES(${wxWidgets_INCLUDE_DIRS})
|
||||
INCLUDE(${wxWidgets_USE_FILE})
|
||||
TARGET_LINK_LIBRARIES(AnimView ${wxWidgets_LIBRARIES})
|
||||
set(wxWidgets_USE_LIBS core base) # optionally: more than wx std libs
|
||||
find_package(wxWidgets REQUIRED)
|
||||
if(wxWidgets_FOUND)
|
||||
link_libraries(${wxWidgets_LIBRARIES})
|
||||
include_directories(${wxWidgets_INCLUDE_DIRS})
|
||||
include(${wxWidgets_USE_FILE})
|
||||
target_link_libraries(AnimView ${wxWidgets_LIBRARIES})
|
||||
message(" wxWidgets found")
|
||||
ELSE(wxWidgets_FOUND)
|
||||
else()
|
||||
message(FATAL_ERROR "error: wxWdigets library not found, it is required to build")
|
||||
message("Make sure the path is correctly defined or set the environment variable WXWIN to the correct location")
|
||||
ENDIF(wxWidgets_FOUND)
|
||||
endif()
|
||||
|
||||
# Basic platform dependant stuff
|
||||
IF(UNIX)
|
||||
IF(APPLE)
|
||||
if(UNIX)
|
||||
if(APPLE)
|
||||
# fruit goes here
|
||||
ELSE(APPLE)
|
||||
else()
|
||||
# regular unix/linux
|
||||
ENDIF(APPLE)
|
||||
ELSE(UNIX)
|
||||
IF(WIN32)
|
||||
endif()
|
||||
else()
|
||||
if(WIN32)
|
||||
# Win32 specific
|
||||
IF(MSVC)
|
||||
if(MSVC)
|
||||
# We want to bind against the very latest versions of the MSVC runtimes
|
||||
add_definitions(/D "_BIND_TO_CURRENT_VCLIBS_VERSION=1")
|
||||
ELSE(MSVC)
|
||||
IF(MSYS)
|
||||
else()
|
||||
if(MSYS)
|
||||
# MSYS stuff
|
||||
ELSE(MSYS)
|
||||
else()
|
||||
# What's left? MINGW? CYGWIN? BORLAND?
|
||||
ENDIF(MSYS)
|
||||
ENDIF(MSVC)
|
||||
ELSE(WIN32)
|
||||
endif()
|
||||
endif()
|
||||
else()
|
||||
# other OS (not UNIX, not 32/64 bit Windows)
|
||||
ENDIF(WIN32)
|
||||
ENDIF(UNIX)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
IF(APPLE)
|
||||
if(APPLE)
|
||||
install(TARGETS AnimView BUNDLE DESTINATION .)
|
||||
|
||||
# Fix the OS X bundle to include required libraries (create a redistributable app)
|
||||
@@ -102,7 +100,7 @@ IF(APPLE)
|
||||
SET(BU_CHMOD_BUNDLE_ITEMS ON)
|
||||
FIXUP_BUNDLE(${CMAKE_INSTALL_PREFIX}/AnimView.app \"\" \"\")
|
||||
")
|
||||
ELSE()
|
||||
else()
|
||||
install(TARGETS AnimView RUNTIME DESTINATION AnimView)
|
||||
install(FILES LICENSE.txt DESTINATION AnimView )
|
||||
ENDIF()
|
||||
endif()
|
||||
|
@@ -11,12 +11,12 @@
|
||||
# Marks the given component as found if both *_LIBRARIES AND *_INCLUDE_DIRS is present.
|
||||
#
|
||||
macro(set_component_found _component )
|
||||
if (${_component}_LIBRARIES AND ${_component}_INCLUDE_DIRS)
|
||||
if(${_component}_LIBRARIES AND ${_component}_INCLUDE_DIRS)
|
||||
# message(STATUS " - ${_component} found.")
|
||||
set(${_component}_FOUND TRUE)
|
||||
else ()
|
||||
else()
|
||||
# message(STATUS " - ${_component} not found.")
|
||||
endif ()
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
#
|
||||
@@ -27,7 +27,6 @@ endmacro()
|
||||
# component's version and sets *_VERSION_STRING.
|
||||
#
|
||||
macro(find_component _component _library _header _version)
|
||||
|
||||
find_path(${_component}_INCLUDE_DIRS ${_header}
|
||||
PATH_SUFFIXES
|
||||
ffmpeg
|
||||
@@ -41,7 +40,7 @@ macro(find_component _component _library _header _version)
|
||||
lib
|
||||
)
|
||||
|
||||
if (${_component}_INCLUDE_DIRS AND EXISTS "${${_component}_INCLUDE_DIRS}/${_version}")
|
||||
if(${_component}_INCLUDE_DIRS AND EXISTS "${${_component}_INCLUDE_DIRS}/${_version}")
|
||||
file(STRINGS "${${_component}_INCLUDE_DIRS}/${_version}" ${_component}_VERSION_MAJOR_LINE REGEX "^#define[ \t]+LIB${_component}_VERSION_MAJOR[ \t]+[0-9]+$")
|
||||
file(STRINGS "${${_component}_INCLUDE_DIRS}/${_version}" ${_component}_VERSION_MINOR_LINE REGEX "^#define[ \t]+LIB${_component}_VERSION_MINOR[ \t]+[0-9]+$")
|
||||
file(STRINGS "${${_component}_INCLUDE_DIRS}/${_version}" ${_component}_VERSION_PATCH_LINE REGEX "^#define[ \t]+LIB${_component}_VERSION_MICRO[ \t]+[0-9]+$")
|
||||
@@ -55,11 +54,12 @@ macro(find_component _component _library _header _version)
|
||||
unset(${_component}_VERSION_MAJOR)
|
||||
unset(${_component}_VERSION_MINOR)
|
||||
unset(${_component}_VERSION_PATCH)
|
||||
endif ()
|
||||
endif()
|
||||
|
||||
find_package_handle_standard_args(${_component}
|
||||
REQUIRED_VARS ${_component}_LIBRARIES ${_component}_INCLUDE_DIRS
|
||||
VERSION_VAR ${_component}_VERSION_STRING)
|
||||
VERSION_VAR ${_component}_VERSION_STRING
|
||||
)
|
||||
|
||||
set_component_found(${_component})
|
||||
|
||||
endmacro()
|
||||
|
@@ -2,28 +2,34 @@
|
||||
add_custom_command(TARGET CorsixTH POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_directory
|
||||
"${VCPKG_INSTALLED_PATH}/share/lua"
|
||||
$<TARGET_FILE_DIR:CorsixTH>)
|
||||
$<TARGET_FILE_DIR:CorsixTH>
|
||||
)
|
||||
|
||||
add_custom_command(TARGET CorsixTH POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E remove
|
||||
$<TARGET_FILE_DIR:CorsixTH>/COPYRIGHT)
|
||||
$<TARGET_FILE_DIR:CorsixTH>/COPYRIGHT
|
||||
)
|
||||
|
||||
add_custom_command(TARGET CorsixTH POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy
|
||||
"${VCPKG_INSTALLED_PATH}/$<$<CONFIG:Debug>:debug/>bin/lfs.dll"
|
||||
$<TARGET_FILE_DIR:CorsixTH>/lfs.dll)
|
||||
$<TARGET_FILE_DIR:CorsixTH>/lfs.dll
|
||||
)
|
||||
|
||||
add_custom_command(TARGET CorsixTH POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy
|
||||
"${VCPKG_INSTALLED_PATH}/$<$<CONFIG:Debug>:debug/>bin/lpeg.dll"
|
||||
$<TARGET_FILE_DIR:CorsixTH>/lpeg.dll)
|
||||
$<TARGET_FILE_DIR:CorsixTH>/lpeg.dll
|
||||
)
|
||||
|
||||
add_custom_command(TARGET CorsixTH POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy
|
||||
"${VCPKG_INSTALLED_PATH}/$<$<CONFIG:Debug>:debug/>bin/mime/core.dll"
|
||||
$<TARGET_FILE_DIR:CorsixTH>/mime/core.dll)
|
||||
$<TARGET_FILE_DIR:CorsixTH>/mime/core.dll
|
||||
)
|
||||
|
||||
add_custom_command(TARGET CorsixTH POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy
|
||||
"${VCPKG_INSTALLED_PATH}/$<$<CONFIG:Debug>:debug/>bin/socket/core.dll"
|
||||
$<TARGET_FILE_DIR:CorsixTH>/socket/core.dll)
|
||||
$<TARGET_FILE_DIR:CorsixTH>/socket/core.dll
|
||||
)
|
||||
|
@@ -60,15 +60,14 @@ if(WIN32) # The only platform it makes sense to check for DirectX SDK
|
||||
# lib files are in DirectX_ROOT_DIR/Lib/x64|x86
|
||||
if(CMAKE_CL_64)
|
||||
set(DirectX_LIBPATH_SUFFIX "x64")
|
||||
else(CMAKE_CL_64)
|
||||
else()
|
||||
set(DirectX_LIBPATH_SUFFIX "x86")
|
||||
endif(CMAKE_CL_64)
|
||||
endif()
|
||||
find_library(DirectX_LIBRARY NAMES d3d9 HINTS ${DirectX_LIB_SEARCH_PATH} PATH_SUFFIXES ${DirectX_LIBPATH_SUFFIX})
|
||||
find_library(DirectX_D3DX9_LIBRARY NAMES d3dx9 HINTS ${DirectX_LIB_SEARCH_PATH} PATH_SUFFIXES ${DirectX_LIBPATH_SUFFIX})
|
||||
find_library(DirectX_DXERR_LIBRARY NAMES DxErr HINTS ${DirectX_LIB_SEARCH_PATH} PATH_SUFFIXES ${DirectX_LIBPATH_SUFFIX})
|
||||
find_library(DirectX_DXGUID_LIBRARY NAMES dxguid HINTS ${DirectX_LIB_SEARCH_PATH} PATH_SUFFIXES ${DirectX_LIBPATH_SUFFIX})
|
||||
|
||||
|
||||
# look for dxgi (needed by both 10 and 11)
|
||||
find_library(DirectX_DXGI_LIBRARY NAMES dxgi HINTS ${DirectX_LIB_SEARCH_PATH} PATH_SUFFIXES ${DirectX_LIBPATH_SUFFIX})
|
||||
|
||||
@@ -83,17 +82,17 @@ if(WIN32) # The only platform it makes sense to check for DirectX SDK
|
||||
)
|
||||
|
||||
mark_as_advanced(DirectX_D3DX9_LIBRARY DirectX_DXERR_LIBRARY DirectX_DXGUID_LIBRARY
|
||||
DirectX_DXGI_LIBRARY DirectX_D3DCOMPILER_LIBRARY)
|
||||
|
||||
DirectX_DXGI_LIBRARY DirectX_D3DCOMPILER_LIBRARY
|
||||
)
|
||||
|
||||
# look for D3D11 components
|
||||
if (DirectX_FOUND)
|
||||
if(DirectX_FOUND)
|
||||
find_path(DirectX_D3D11_INCLUDE_DIR NAMES D3D11Shader.h HINTS ${DirectX_INC_SEARCH_PATH})
|
||||
get_filename_component(DirectX_LIBRARY_DIR "${DirectX_LIBRARY}" PATH)
|
||||
message(STATUS "DX lib dir: ${DirectX_LIBRARY_DIR}")
|
||||
find_library(DirectX_D3D11_LIBRARY NAMES d3d11 HINTS ${DirectX_LIB_SEARCH_PATH} PATH_SUFFIXES ${DirectX_LIBPATH_SUFFIX})
|
||||
find_library(DirectX_D3DX11_LIBRARY NAMES d3dx11 HINTS ${DirectX_LIB_SEARCH_PATH} PATH_SUFFIXES ${DirectX_LIBPATH_SUFFIX})
|
||||
if (DirectX_D3D11_INCLUDE_DIR AND DirectX_D3D11_LIBRARY)
|
||||
if(DirectX_D3D11_INCLUDE_DIR AND DirectX_D3D11_LIBRARY)
|
||||
set(DirectX_D3D11_FOUND TRUE)
|
||||
set(DirectX_D3D11_INCLUDE_DIR ${DirectX_D3D11_INCLUDE_DIR})
|
||||
set(DirectX_D3D11_LIBRARIES ${DirectX_D3D11_LIBRARIES}
|
||||
@@ -102,14 +101,13 @@ if(WIN32) # The only platform it makes sense to check for DirectX SDK
|
||||
${DirectX_DXGUID_LIBRARY}
|
||||
${DirectX_D3DCOMPILER_LIBRARY}
|
||||
)
|
||||
endif ()
|
||||
if (DirectX_D3DX11_LIBRARY)
|
||||
endif()
|
||||
if(DirectX_D3DX11_LIBRARY)
|
||||
set(DirectX_D3D11_LIBRARIES ${DirectX_D3D11_LIBRARIES} ${DirectX_D3DX11_LIBRARY})
|
||||
endif ()
|
||||
if (DirectX_DXERR_LIBRARY)
|
||||
endif()
|
||||
if(DirectX_DXERR_LIBRARY)
|
||||
set(DirectX_D3D11_LIBRARIES ${DirectX_D3D11_LIBRARIES} ${DirectX_DXERR_LIBRARY})
|
||||
endif ()
|
||||
endif()
|
||||
mark_as_advanced(DirectX_D3D11_INCLUDE_DIR DirectX_D3D11_LIBRARY DirectX_D3DX11_LIBRARY)
|
||||
endif ()
|
||||
|
||||
endif(WIN32)
|
||||
endif()
|
||||
endif()
|
||||
|
@@ -33,12 +33,12 @@ include(FindPackageHandleStandardArgs)
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/CMakeFFmpegLibavMacros.cmake)
|
||||
|
||||
# The default components were taken from a survey over other FindFFMPEG.cmake files
|
||||
if (NOT FFmpeg_FIND_COMPONENTS)
|
||||
if(NOT FFmpeg_FIND_COMPONENTS)
|
||||
set(FFmpeg_FIND_COMPONENTS AVCODEC AVFORMAT AVUTIL)
|
||||
endif ()
|
||||
endif()
|
||||
|
||||
# Check for cached results. If there are skip the costly part.
|
||||
if (NOT FFMPEG_LIBRARIES)
|
||||
if(NOT FFMPEG_LIBRARIES)
|
||||
|
||||
# Check for all possible component.
|
||||
find_component(AVCODEC avcodec libavcodec/avcodec.h libavcodec/version.h)
|
||||
@@ -50,40 +50,38 @@ if (NOT FFMPEG_LIBRARIES)
|
||||
find_component(SWRESAMPLE swresample libswresample/swresample.h libswresample/version.h)
|
||||
|
||||
# Check if the required components were found and add their stuff to the FFMPEG_* vars.
|
||||
foreach (_component ${FFmpeg_FIND_COMPONENTS})
|
||||
if (${_component}_FOUND)
|
||||
foreach(_component ${FFmpeg_FIND_COMPONENTS})
|
||||
if(${_component}_FOUND)
|
||||
# message(STATUS "Required component ${_component} present.")
|
||||
set(FFMPEG_LIBRARIES ${FFMPEG_LIBRARIES} ${${_component}_LIBRARIES})
|
||||
list(APPEND FFMPEG_INCLUDE_DIRS ${${_component}_INCLUDE_DIRS})
|
||||
else ()
|
||||
else()
|
||||
# message(STATUS "Required component ${_component} missing.")
|
||||
endif ()
|
||||
endforeach ()
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
# Build the include path with duplicates removed.
|
||||
if (FFMPEG_INCLUDE_DIRS)
|
||||
if(FFMPEG_INCLUDE_DIRS)
|
||||
list(REMOVE_DUPLICATES FFMPEG_INCLUDE_DIRS)
|
||||
endif ()
|
||||
endif()
|
||||
|
||||
# cache the vars.
|
||||
set(FFMPEG_INCLUDE_DIRS ${FFMPEG_INCLUDE_DIRS} CACHE STRING "The FFmpeg include directories." FORCE)
|
||||
set(FFMPEG_LIBRARIES ${FFMPEG_LIBRARIES} CACHE STRING "The FFmpeg libraries." FORCE)
|
||||
|
||||
mark_as_advanced(FFMPEG_INCLUDE_DIRS
|
||||
FFMPEG_LIBRARIES)
|
||||
|
||||
endif ()
|
||||
mark_as_advanced(FFMPEG_INCLUDE_DIRS FFMPEG_LIBRARIES)
|
||||
endif()
|
||||
|
||||
# Now set the noncached _FOUND vars for the components.
|
||||
foreach (_component AVCODEC AVDEVICE AVFORMAT AVUTIL POSTPROCESS SWSCALE SWRESAMPLE)
|
||||
foreach(_component AVCODEC AVDEVICE AVFORMAT AVUTIL POSTPROCESS SWSCALE SWRESAMPLE)
|
||||
set_component_found(${_component})
|
||||
endforeach ()
|
||||
endforeach()
|
||||
|
||||
# Compile the list of required vars
|
||||
set(_FFmpeg_REQUIRED_VARS FFMPEG_LIBRARIES FFMPEG_INCLUDE_DIRS)
|
||||
foreach (_component ${FFmpeg_FIND_COMPONENTS})
|
||||
foreach(_component ${FFmpeg_FIND_COMPONENTS})
|
||||
list(APPEND _FFmpeg_REQUIRED_VARS ${_component}_LIBRARIES ${_component}_INCLUDE_DIRS)
|
||||
endforeach ()
|
||||
endforeach()
|
||||
|
||||
# Give a nice error message if some of the required vars are missing.
|
||||
find_package_handle_standard_args(FFmpeg DEFAULT_MSG ${_FFmpeg_REQUIRED_VARS})
|
||||
|
@@ -33,12 +33,12 @@ include(FindPackageHandleStandardArgs)
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/CMakeFFmpegLibavMacros.cmake)
|
||||
|
||||
# The default components were taken from a survey over other FindLIBAV.cmake files
|
||||
if (NOT LibAV_FIND_COMPONENTS)
|
||||
if(NOT LibAV_FIND_COMPONENTS)
|
||||
set(LibAV_FIND_COMPONENTS AVCODEC AVFORMAT AVUTIL)
|
||||
endif ()
|
||||
endif()
|
||||
|
||||
# Check for cached results. If there are skip the costly part.
|
||||
if (NOT LIBAV_LIBRARIES)
|
||||
if(NOT LIBAV_LIBRARIES)
|
||||
|
||||
# Check for all possible component.
|
||||
find_component(AVCODEC avcodec libavcodec/avcodec.h libavcodec/version.h)
|
||||
@@ -50,40 +50,38 @@ if (NOT LIBAV_LIBRARIES)
|
||||
find_component(SWSCALE swscale libswscale/swscale.h libswscale/version.h)
|
||||
|
||||
# Check if the required components were found and add their stuff to the LIBAV_* vars.
|
||||
foreach (_component ${LibAV_FIND_COMPONENTS})
|
||||
if (${_component}_FOUND)
|
||||
foreach(_component ${LibAV_FIND_COMPONENTS})
|
||||
if(${_component}_FOUND)
|
||||
# message(STATUS "Required component ${_component} present.")
|
||||
set(LIBAV_LIBRARIES ${LIBAV_LIBRARIES} ${${_component}_LIBRARIES})
|
||||
list(APPEND LIBAV_INCLUDE_DIRS ${${_component}_INCLUDE_DIRS})
|
||||
else ()
|
||||
else()
|
||||
# message(STATUS "Required component ${_component} missing.")
|
||||
endif ()
|
||||
endforeach ()
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
# Build the include path with duplicates removed.
|
||||
if (LIBAV_INCLUDE_DIRS)
|
||||
if(LIBAV_INCLUDE_DIRS)
|
||||
list(REMOVE_DUPLICATES LIBAV_INCLUDE_DIRS)
|
||||
endif ()
|
||||
endif()
|
||||
|
||||
# cache the vars.
|
||||
set(LIBAV_INCLUDE_DIRS ${LIBAV_INCLUDE_DIRS} CACHE STRING "The LibAV include directories." FORCE)
|
||||
set(LIBAV_LIBRARIES ${LIBAV_LIBRARIES} CACHE STRING "The LibAV libraries." FORCE)
|
||||
|
||||
mark_as_advanced(LIBAV_INCLUDE_DIRS
|
||||
LIBAV_LIBRARIES)
|
||||
|
||||
endif ()
|
||||
mark_as_advanced(LIBAV_INCLUDE_DIRS LIBAV_LIBRARIES)
|
||||
endif()
|
||||
|
||||
# Now set the noncached _FOUND vars for the components.
|
||||
foreach (_component AVCODEC AVDEVICE AVFILTER AVFORMAT AVRESAMPLE AVUTIL SWSCALE)
|
||||
foreach(_component AVCODEC AVDEVICE AVFILTER AVFORMAT AVRESAMPLE AVUTIL SWSCALE)
|
||||
set_component_found(${_component})
|
||||
endforeach ()
|
||||
endforeach()
|
||||
|
||||
# Compile the list of required vars
|
||||
set(_LibAV_REQUIRED_VARS LIBAV_LIBRARIES LIBAV_INCLUDE_DIRS)
|
||||
foreach (_component ${LibAV_FIND_COMPONENTS})
|
||||
foreach(_component ${LibAV_FIND_COMPONENTS})
|
||||
list(APPEND _LibAV_REQUIRED_VARS ${_component}_LIBRARIES ${_component}_INCLUDE_DIRS)
|
||||
endforeach ()
|
||||
endforeach()
|
||||
|
||||
# Give a nice error message if some of the required vars are missing.
|
||||
find_package_handle_standard_args(LibAV DEFAULT_MSG ${_LibAV_REQUIRED_VARS})
|
||||
|
@@ -16,21 +16,20 @@
|
||||
# UNSET(LUA_LIBRARY CACHE)
|
||||
# FIND_PACKAGE (Lua REQUIRED)
|
||||
|
||||
SET (Lua_FOUND FALSE)
|
||||
set(Lua_FOUND FALSE)
|
||||
set(LUA_INTERPRETER_TYPE "")
|
||||
|
||||
SET (LUA_INTERPRETER_TYPE "")
|
||||
if(WITH_LUAJIT)
|
||||
set(LUA_INTERPRETER_TYPE "LuaJIT")
|
||||
set(LUA_LIBRARY_NAME luajit-5.1 lua51)
|
||||
set(LUA_INCLUDE_DIRS include/luajit-2.0 include)
|
||||
else()
|
||||
set(LUA_INTERPRETER_TYPE "Lua")
|
||||
set(LUA_LIBRARY_NAME lua53 lua5.3 lua-5.3 liblua.5.3.dylib lua52 lua5.2 lua-5.2 liblua.5.2.dylib lua51 lua5.1 lua-5.1 liblua.5.1.dylib lua liblua)
|
||||
set(LUA_INCLUDE_DIRS include/lua53 include/lua5.3 include/lua-5.3 include/lua52 include/lua5.2 include/lua-5.2 include/lua51 include/lua5.1 include/lua-5.1 include/lua include)
|
||||
endif()
|
||||
|
||||
IF (WITH_LUAJIT)
|
||||
SET (LUA_INTERPRETER_TYPE "LuaJIT")
|
||||
SET (LUA_LIBRARY_NAME luajit-5.1 lua51)
|
||||
SET (LUA_INCLUDE_DIRS include/luajit-2.0 include)
|
||||
ELSE (WITH_LUAJIT)
|
||||
SET (LUA_INTERPRETER_TYPE "Lua")
|
||||
SET (LUA_LIBRARY_NAME lua53 lua5.3 lua-5.3 liblua.5.3.dylib lua52 lua5.2 lua-5.2 liblua.5.2.dylib lua51 lua5.1 lua-5.1 liblua.5.1.dylib lua liblua)
|
||||
SET (LUA_INCLUDE_DIRS include/lua53 include/lua5.3 include/lua-5.3 include/lua52 include/lua5.2 include/lua-5.2 include/lua51 include/lua5.1 include/lua-5.1 include/lua include)
|
||||
ENDIF(WITH_LUAJIT)
|
||||
|
||||
FIND_PATH (LUA_INCLUDE_DIR lua.h
|
||||
find_path(LUA_INCLUDE_DIR lua.h
|
||||
HINTS
|
||||
ENV LUA_DIR
|
||||
PATH_SUFFIXES ${LUA_INCLUDE_DIRS}
|
||||
@@ -43,7 +42,7 @@ FIND_PATH (LUA_INCLUDE_DIR lua.h
|
||||
~/Library/Frameworks
|
||||
/Library/Frameworks
|
||||
)
|
||||
FIND_LIBRARY (LUA_LIBRARY NAMES ${LUA_LIBRARY_NAME}
|
||||
find_library(LUA_LIBRARY NAMES ${LUA_LIBRARY_NAME}
|
||||
HINTS
|
||||
ENV LUA_DIR
|
||||
PATH_SUFFIXES lib
|
||||
@@ -57,30 +56,30 @@ FIND_LIBRARY (LUA_LIBRARY NAMES ${LUA_LIBRARY_NAME}
|
||||
/Library/Frameworks
|
||||
)
|
||||
|
||||
IF (NOT LUA_INCLUDE_DIR)
|
||||
MESSAGE(FATAL_ERROR "Could Not Find Lua Include Dir")
|
||||
ENDIF (NOT LUA_INCLUDE_DIR)
|
||||
if(NOT LUA_INCLUDE_DIR)
|
||||
message(FATAL_ERROR "Could Not Find Lua Include Dir")
|
||||
endif()
|
||||
|
||||
IF (NOT LUA_LIBRARY)
|
||||
MESSAGE(FATAL_ERROR "Could Not Find Lua Library")
|
||||
ENDIF (NOT LUA_LIBRARY)
|
||||
if(NOT LUA_LIBRARY)
|
||||
message(FATAL_ERROR "Could Not Find Lua Library")
|
||||
endif()
|
||||
|
||||
|
||||
IF (LUA_INCLUDE_DIR AND LUA_LIBRARY)
|
||||
SET (Lua_FOUND TRUE)
|
||||
ENDIF (LUA_INCLUDE_DIR AND LUA_LIBRARY)
|
||||
if(LUA_INCLUDE_DIR AND LUA_LIBRARY)
|
||||
set(Lua_FOUND TRUE)
|
||||
endif()
|
||||
|
||||
IF (Lua_FOUND)
|
||||
IF (NOT Lua_FIND_QUIETLY)
|
||||
MESSAGE(STATUS "Found ${LUA_INTERPRETER_TYPE} library: ${LUA_LIBRARY}")
|
||||
ENDIF (NOT Lua_FIND_QUIETLY)
|
||||
ELSE (Lua_FOUND)
|
||||
IF (Lua_FIND_REQUIRED)
|
||||
if(Lua_FOUND)
|
||||
if(NOT Lua_FIND_QUIETLY)
|
||||
message(STATUS "Found ${LUA_INTERPRETER_TYPE} library: ${LUA_LIBRARY}")
|
||||
endif()
|
||||
else (Lua_FOUND)
|
||||
if(Lua_FIND_REQUIRED)
|
||||
MESSAGE(FATAL_ERROR "Could not find ${LUA_INTERPRETER_TYPE}")
|
||||
ENDIF (Lua_FIND_REQUIRED)
|
||||
ENDIF (Lua_FOUND)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
INCLUDE(FindPackageHandleStandardArgs)
|
||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Lua DEFAULT_MSG LUA_LIBRARY LUA_INCLUDE_DIR)
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(Lua DEFAULT_MSG LUA_LIBRARY LUA_INCLUDE_DIR)
|
||||
|
||||
MARK_AS_ADVANCED ( LUA_INCLUDE_DIR LUA_LIBRARY)
|
||||
mark_as_advanced(LUA_INCLUDE_DIR LUA_LIBRARY)
|
||||
|
@@ -15,36 +15,39 @@
|
||||
|
||||
# Begin processing of package
|
||||
macro(findpkg_begin PREFIX)
|
||||
if (NOT ${PREFIX}_FIND_QUIETLY)
|
||||
if(NOT ${PREFIX}_FIND_QUIETLY)
|
||||
message(STATUS "Looking for ${PREFIX}...")
|
||||
endif ()
|
||||
endif()
|
||||
endmacro(findpkg_begin)
|
||||
|
||||
# Display a status message unless FIND_QUIETLY is set
|
||||
macro(pkg_message PREFIX)
|
||||
if (NOT ${PREFIX}_FIND_QUIETLY)
|
||||
if(NOT ${PREFIX}_FIND_QUIETLY)
|
||||
message(STATUS ${ARGN})
|
||||
endif ()
|
||||
endif()
|
||||
endmacro(pkg_message)
|
||||
|
||||
# Get environment variable, define it as ENV_$var and make sure backslashes are converted to forward slashes
|
||||
macro(getenv_path VAR)
|
||||
set(ENV_${VAR} $ENV{${VAR}})
|
||||
# replace won't work if var is blank
|
||||
if (ENV_${VAR})
|
||||
if(ENV_${VAR})
|
||||
string( REGEX REPLACE "\\\\" "/" ENV_${VAR} ${ENV_${VAR}} )
|
||||
endif ()
|
||||
endif()
|
||||
endmacro(getenv_path)
|
||||
|
||||
# Construct search paths for includes and libraries from a PREFIX_PATH
|
||||
macro(create_search_paths PREFIX)
|
||||
foreach(dir ${${PREFIX}_PREFIX_PATH})
|
||||
set(${PREFIX}_INC_SEARCH_PATH ${${PREFIX}_INC_SEARCH_PATH}
|
||||
${dir}/include ${dir}/Include ${dir}/include/${PREFIX} ${dir}/Headers)
|
||||
${dir}/include ${dir}/Include ${dir}/include/${PREFIX} ${dir}/Headers
|
||||
)
|
||||
set(${PREFIX}_LIB_SEARCH_PATH ${${PREFIX}_LIB_SEARCH_PATH}
|
||||
${dir}/lib ${dir}/Lib ${dir}/lib/${PREFIX} ${dir}/Libs)
|
||||
${dir}/lib ${dir}/Lib ${dir}/lib/${PREFIX} ${dir}/Libs
|
||||
)
|
||||
set(${PREFIX}_BIN_SEARCH_PATH ${${PREFIX}_BIN_SEARCH_PATH}
|
||||
${dir}/bin)
|
||||
${dir}/bin
|
||||
)
|
||||
endforeach(dir)
|
||||
set(${PREFIX}_FRAMEWORK_SEARCH_PATH ${${PREFIX}_PREFIX_PATH})
|
||||
endmacro(create_search_paths)
|
||||
@@ -57,34 +60,34 @@ macro(clear_if_changed TESTVAR)
|
||||
# at the same time ensure that we are actually dealing with a list.
|
||||
list(APPEND ${TESTVAR} "")
|
||||
list(REMOVE_ITEM ${TESTVAR} "")
|
||||
if (NOT "${${TESTVAR}}" STREQUAL "${${TESTVAR}_INT_CHECK}")
|
||||
if(NOT "${${TESTVAR}}" STREQUAL "${${TESTVAR}_INT_CHECK}")
|
||||
message(STATUS "${TESTVAR} changed.")
|
||||
foreach(var ${ARGN})
|
||||
set(${var} "NOTFOUND" CACHE STRING "x" FORCE)
|
||||
endforeach(var)
|
||||
endif ()
|
||||
endif()
|
||||
set(${TESTVAR}_INT_CHECK ${${TESTVAR}} CACHE INTERNAL "x" FORCE)
|
||||
endmacro(clear_if_changed)
|
||||
|
||||
# Try to get some hints from pkg-config, if available
|
||||
macro(use_pkgconfig PREFIX PKGNAME)
|
||||
find_package(PkgConfig)
|
||||
if (PKG_CONFIG_FOUND)
|
||||
if(PKG_CONFIG_FOUND)
|
||||
pkg_check_modules(${PREFIX} ${PKGNAME})
|
||||
endif ()
|
||||
endmacro (use_pkgconfig)
|
||||
endif()
|
||||
endmacro(use_pkgconfig)
|
||||
|
||||
# Couple a set of release AND debug libraries (or frameworks)
|
||||
macro(make_library_set PREFIX)
|
||||
if (${PREFIX}_FWK)
|
||||
if(${PREFIX}_FWK)
|
||||
set(${PREFIX} ${${PREFIX}_FWK})
|
||||
elseif (${PREFIX}_REL AND ${PREFIX}_DBG)
|
||||
elseif(${PREFIX}_REL AND ${PREFIX}_DBG)
|
||||
set(${PREFIX} optimized ${${PREFIX}_REL} debug ${${PREFIX}_DBG})
|
||||
elseif (${PREFIX}_REL)
|
||||
elseif(${PREFIX}_REL)
|
||||
set(${PREFIX} ${${PREFIX}_REL})
|
||||
elseif (${PREFIX}_DBG)
|
||||
elseif(${PREFIX}_DBG)
|
||||
set(${PREFIX} ${${PREFIX}_DBG})
|
||||
endif ()
|
||||
endif()
|
||||
endmacro(make_library_set)
|
||||
|
||||
# Generate debug names from given release names
|
||||
@@ -103,28 +106,27 @@ endmacro(add_parent_dir)
|
||||
# Do the final processing for the package find.
|
||||
macro(findpkg_finish PREFIX)
|
||||
# skip if already processed during this run
|
||||
if (NOT ${PREFIX}_FOUND)
|
||||
if (${PREFIX}_INCLUDE_DIR AND ${PREFIX}_LIBRARY)
|
||||
if(NOT ${PREFIX}_FOUND)
|
||||
if(${PREFIX}_INCLUDE_DIR AND ${PREFIX}_LIBRARY)
|
||||
set(${PREFIX}_FOUND TRUE)
|
||||
set(${PREFIX}_INCLUDE_DIRS ${${PREFIX}_INCLUDE_DIR})
|
||||
set(${PREFIX}_LIBRARIES ${${PREFIX}_LIBRARY})
|
||||
if (NOT ${PREFIX}_FIND_QUIETLY)
|
||||
if(NOT ${PREFIX}_FIND_QUIETLY)
|
||||
message(STATUS "Found ${PREFIX}: ${${PREFIX}_LIBRARIES}")
|
||||
endif ()
|
||||
else ()
|
||||
if (NOT ${PREFIX}_FIND_QUIETLY)
|
||||
endif()
|
||||
else()
|
||||
if(NOT ${PREFIX}_FIND_QUIETLY)
|
||||
message(STATUS "Could not locate ${PREFIX}")
|
||||
endif ()
|
||||
if (${PREFIX}_FIND_REQUIRED)
|
||||
endif()
|
||||
if(${PREFIX}_FIND_REQUIRED)
|
||||
message(FATAL_ERROR "Required library ${PREFIX} not found! Install the library (including dev packages) and try again. If the library is already installed, set the missing variables manually in cmake.")
|
||||
endif ()
|
||||
endif ()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
mark_as_advanced(${PREFIX}_INCLUDE_DIR ${PREFIX}_LIBRARY ${PREFIX}_LIBRARY_REL ${PREFIX}_LIBRARY_DBG ${PREFIX}_LIBRARY_FWK)
|
||||
endif ()
|
||||
endif()
|
||||
endmacro(findpkg_finish)
|
||||
|
||||
|
||||
# Slightly customised framework finder
|
||||
macro(findpkg_framework fwk)
|
||||
if(APPLE)
|
||||
@@ -153,10 +155,10 @@ macro(findpkg_framework fwk)
|
||||
set(${fwk}_FRAMEWORK_INCLUDES ${${fwk}_FRAMEWORK_INCLUDES}
|
||||
${fwkpath}/Headers ${fwkpath}/PrivateHeaders)
|
||||
set(${fwk}_FRAMEWORK_PATH ${dir})
|
||||
if (NOT ${fwk}_LIBRARY_FWK)
|
||||
if(NOT ${fwk}_LIBRARY_FWK)
|
||||
set(${fwk}_LIBRARY_FWK "-framework ${fwk}")
|
||||
endif ()
|
||||
endif(EXISTS ${fwkpath})
|
||||
endif()
|
||||
endif()
|
||||
endforeach(dir)
|
||||
endif(APPLE)
|
||||
endif()
|
||||
endmacro(findpkg_framework)
|
||||
|
@@ -152,7 +152,7 @@ endif()
|
||||
#include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
|
||||
include(FindPackageHandleStandardArgs)
|
||||
|
||||
|
||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(SDL
|
||||
find_package_handle_standard_args(SDL
|
||||
REQUIRED_VARS SDL_LIBRARY SDL_INCLUDE_DIR
|
||||
VERSION_VAR SDL_VERSION_STRING)
|
||||
VERSION_VAR SDL_VERSION_STRING
|
||||
)
|
||||
|
@@ -77,9 +77,10 @@ set(SDL_MIXER_INCLUDE_DIRS ${SDL_MIXER_INCLUDE_DIR})
|
||||
#include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
|
||||
include(FindPackageHandleStandardArgs)
|
||||
|
||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(SDL_mixer
|
||||
find_package_handle_standard_args(SDL_mixer
|
||||
REQUIRED_VARS SDL_MIXER_LIBRARIES SDL_MIXER_INCLUDE_DIRS
|
||||
VERSION_VAR SDL_MIXER_VERSION_STRING)
|
||||
VERSION_VAR SDL_MIXER_VERSION_STRING
|
||||
)
|
||||
|
||||
# for backward compatibility
|
||||
set(SDLMIXER_LIBRARY ${SDL_MIXER_LIBRARIES})
|
||||
|
@@ -7,18 +7,18 @@
|
||||
## VLD_LIBRARY
|
||||
##
|
||||
## Stephen E. Baker 2014
|
||||
SET(VLD_FOUND FALSE)
|
||||
set(VLD_FOUND FALSE)
|
||||
|
||||
IF(${CMAKE_SIZEOF_VOID_P} MATCHES 8)
|
||||
SET (VLD_LIB_SUBDIRS lib/Win64 lib)
|
||||
ELSE(${CMAKE_SIZEOF_VOID_P} MATCHES 8)
|
||||
SET (VLD_LIB_SUBDIRS lib/Win32 lib)
|
||||
ENDIF(${CMAKE_SIZEOF_VOID_P} MATCHES 8)
|
||||
if(${CMAKE_SIZEOF_VOID_P} MATCHES 8)
|
||||
set (VLD_LIB_SUBDIRS lib/Win64 lib)
|
||||
else()
|
||||
set (VLD_LIB_SUBDIRS lib/Win32 lib)
|
||||
endif()
|
||||
|
||||
SET (PROG_FILES_X86_ENV "PROGRAMFILES(X86)")
|
||||
SET (PROG_FILES_ENV "PROGRAMFILES")
|
||||
set(PROG_FILES_X86_ENV "PROGRAMFILES(X86)")
|
||||
set(PROG_FILES_ENV "PROGRAMFILES")
|
||||
|
||||
FIND_PATH(VLD_INCLUDE_DIR vld.h
|
||||
find_path(VLD_INCLUDE_DIR vld.h
|
||||
HINTS
|
||||
ENV VLD_HOME
|
||||
PATH_SUFFIXES include
|
||||
@@ -26,9 +26,8 @@ FIND_PATH(VLD_INCLUDE_DIR vld.h
|
||||
"$ENV{${PROG_FILES_X86_ENV}}/Visual Leak Detector"
|
||||
"$ENV{${PROG_FILES_ENV}}/Visual Leak Detector"
|
||||
)
|
||||
#MESSAGE("VLD_INCLUDE_DIR=${VLD_INCLUDE_DIR}")
|
||||
|
||||
FIND_LIBRARY(VLD_LIBRARY NAMES vld
|
||||
find_library(VLD_LIBRARY NAMES vld
|
||||
HINTS
|
||||
ENV VLD_HOME
|
||||
PATH_SUFFIXES ${VLD_LIB_SUBDIRS}
|
||||
@@ -36,16 +35,15 @@ FIND_LIBRARY(VLD_LIBRARY NAMES vld
|
||||
"$ENV{${PROG_FILES_X86_ENV}}/Visual Leak Detector"
|
||||
"$ENV{${PROG_FILES_ENV}}/Visual Leak Detector"
|
||||
)
|
||||
#MESSAGE("VLD_LIBRARY=${VLD_LIBRARY}")
|
||||
|
||||
IF(VLD_INCLUDE_DIR AND VLD_LIBRARY)
|
||||
SET(VLD_FOUND TRUE)
|
||||
ENDIF(VLD_INCLUDE_DIR AND VLD_LIBRARY)
|
||||
if(VLD_INCLUDE_DIR AND VLD_LIBRARY)
|
||||
set(VLD_FOUND TRUE)
|
||||
endif()
|
||||
|
||||
INCLUDE(FindPackageHandleStandardArgs)
|
||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(VLD DEFAULT_MSG VLD_LIBRARY VLD_INCLUDE_DIR)
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(VLD DEFAULT_MSG VLD_LIBRARY VLD_INCLUDE_DIR)
|
||||
|
||||
MARK_AS_ADVANCED(
|
||||
mark_as_advanced(
|
||||
VLD_INCLUDE_DIR
|
||||
VLD_LIBRARY
|
||||
)
|
||||
|
@@ -38,7 +38,8 @@ ExternalProject_Add(${_DEPS_PROJECT_NAME}
|
||||
CONFIGURE_COMMAND ""
|
||||
BUILD_COMMAND ""
|
||||
INSTALL_COMMAND ""
|
||||
TEST_COMMAND "")
|
||||
TEST_COMMAND ""
|
||||
)
|
||||
|
||||
unset(_DEPS_GIT_URL)
|
||||
unset(_DEPS_GIT_SHA)
|
||||
@@ -47,7 +48,8 @@ unset(_DEPS_GIT_SHA)
|
||||
# the dependencies target
|
||||
set_target_properties(${_DEPS_PROJECT_NAME} PROPERTIES
|
||||
EXCLUDE_FROM_ALL 1
|
||||
EXCLUDE_FROM_DEFAULT_BUILD 1)
|
||||
EXCLUDE_FROM_DEFAULT_BUILD 1
|
||||
)
|
||||
|
||||
set(_DEPS_TMP_PATH ${PRECOMPILED_DEPS_BASE_DIR}/tmp)
|
||||
set(_DEPS_MODULES_TEMPLATE_NAME ${_DEPS_TMP_PATH}/${_DEPS_PROJECT_NAME})
|
||||
@@ -57,7 +59,8 @@ if(NOT EXISTS ${PRECOMPILED_DEPS_BASE_DIR}/src/${_DEPS_PROJECT_NAME}/.git)
|
||||
message(STATUS "Getting Precompiled Dependencies...")
|
||||
execute_process(COMMAND ${CMAKE_COMMAND} ARGS -P
|
||||
${_DEPS_MODULES_TEMPLATE_NAME}-gitclone.cmake
|
||||
RESULT_VARIABLE return_value)
|
||||
RESULT_VARIABLE return_value
|
||||
)
|
||||
if(return_value)
|
||||
message(FATAL_ERROR "Failed to clone precompiled dependencies.")
|
||||
endif()
|
||||
@@ -67,7 +70,8 @@ else()
|
||||
message(STATUS "Checking for Precompiled Dependency Updates...")
|
||||
execute_process(COMMAND ${CMAKE_COMMAND} ARGS -P
|
||||
${_DEPS_MODULES_TEMPLATE_NAME}-gitupdate.cmake
|
||||
RESULT_VARIABLE return_value)
|
||||
RESULT_VARIABLE return_value
|
||||
)
|
||||
if(return_value)
|
||||
message(FATAL_ERROR "Failed to update precompiled dependencies.")
|
||||
endif()
|
||||
@@ -82,7 +86,8 @@ if(UNIX AND CMAKE_COMPILER_IS_GNU)
|
||||
# We need user to choose which arch they are intending to compile for
|
||||
set(DEPS_ARCH "x86" CACHE STRING "Architecture of precompiled dependencies to use.")
|
||||
set_property(CACHE DEPS_ARCH
|
||||
PROPERTY STRINGS "x86" "x64")
|
||||
PROPERTY STRINGS "x86" "x64"
|
||||
)
|
||||
# Generate the folder to use
|
||||
set(_DEPS_FOLDER_NAME "gnu-linux-" + ${DEPS_ARCH})
|
||||
else()
|
||||
|
@@ -51,7 +51,8 @@ string(CONCAT _VCPKG_ARGS ${_VCPKG_ARGS} " -VcpkgCommitSha " ${VCPKG_COMMIT_SHA}
|
||||
set(_SCRIPT_COMMAND powershell ${_SCRIPT_DIR}/${_VCPKG_SCRIPT_NAME})
|
||||
execute_process(WORKING_DIRECTORY ${VCPKG_PARENT_DIR}
|
||||
COMMAND ${_SCRIPT_COMMAND} ${_VCPKG_ARGS}
|
||||
RESULT_VARIABLE err_val)
|
||||
RESULT_VARIABLE err_val
|
||||
)
|
||||
if(err_val)
|
||||
message(FATAL_ERROR "Failed to build vcpkg dependencies. "
|
||||
"\nIf this error persists try deleting the 'vcpkg' folder.\n")
|
||||
|
225
CMakeLists.txt
225
CMakeLists.txt
@@ -11,111 +11,113 @@
|
||||
# - WITH_LIBAV : Whether to use LibAV (as opposed to FFMEPG) when building movies
|
||||
# - WITH_VLD : Build with Visual Leak Detector (requires Visual Studio)
|
||||
|
||||
CMAKE_MINIMUM_REQUIRED(VERSION 3.2)
|
||||
cmake_minimum_required(VERSION 3.2)
|
||||
|
||||
SET(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/CMake)
|
||||
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/CMake)
|
||||
|
||||
IF(CMAKE_GENERATOR MATCHES "^Visual Studio 14 2015" OR CMAKE_GENERATOR MATCHES "^Visual Studio 15 2017")
|
||||
OPTION(USE_VCPKG_DEPS "Build vcpkg dependencies locally" OFF)
|
||||
ENDIF()
|
||||
if(CMAKE_GENERATOR MATCHES "^Visual Studio 14 2015" OR CMAKE_GENERATOR MATCHES "^Visual Studio 15 2017")
|
||||
option(USE_VCPKG_DEPS "Build vcpkg dependencies locally" OFF)
|
||||
endif()
|
||||
|
||||
if(USE_VCPKG_DEPS)
|
||||
message("Note: Using locally built vcpkg dependencies.")
|
||||
include(VcpkgDeps)
|
||||
endif()
|
||||
|
||||
PROJECT(CorsixTH_Top_Level)
|
||||
project(CorsixTH_Top_Level)
|
||||
|
||||
INCLUDE(CheckCXXCompilerFlag)
|
||||
CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
|
||||
CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
|
||||
IF(COMPILER_SUPPORTS_CXX11)
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
|
||||
ELSEIF(COMPILER_SUPPORTS_CXX0X)
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
|
||||
ENDIF(COMPILER_SUPPORTS_CXX11)
|
||||
IF (MINGW)
|
||||
include(CheckCXXCompilerFlag)
|
||||
check_cxx_compiler_flag("-std=c++11" COMPILER_SUPPORTS_CXX11)
|
||||
check_cxx_compiler_flag("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
|
||||
if(COMPILER_SUPPORTS_CXX11)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
|
||||
elseif(COMPILER_SUPPORTS_CXX0X)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
|
||||
endif()
|
||||
|
||||
if(MINGW)
|
||||
set(CMAKE_EXE_LINKER_FLAGS "-static-libgcc -static-libstdc++")
|
||||
ENDIF(MINGW)
|
||||
INCLUDE(CheckIncludeFiles)
|
||||
SET(CORSIX_TH_DONE_TOP_LEVEL_CMAKE ON)
|
||||
endif()
|
||||
|
||||
include(CheckIncludeFiles)
|
||||
|
||||
set(CORSIX_TH_DONE_TOP_LEVEL_CMAKE ON)
|
||||
|
||||
# Dependency management
|
||||
if ( UNIX AND CMAKE_COMPILER_IS_GNU)
|
||||
OPTION(USE_PRECOMPILED_DEPS "Use Precompiled Dependencies" OFF) # Make *nix systems opt in
|
||||
if(UNIX AND CMAKE_COMPILER_IS_GNU)
|
||||
option(USE_PRECOMPILED_DEPS "Use Precompiled Dependencies" OFF) # Make *nix systems opt in
|
||||
endif()
|
||||
|
||||
# Define our options
|
||||
OPTION(WITH_SDL "Activate SDL Renderer" ON) # our default option
|
||||
OPTION(WITH_AUDIO "Activate Sound" ON) # enabled by default
|
||||
OPTION(WITH_MOVIES "Activate in game movies" ON)
|
||||
OPTION(WITH_FREETYPE2 "Enhanced Font Support" ON)
|
||||
OPTION(WITH_LUAJIT "Use LuaJIT instead of Lua" OFF)
|
||||
OPTION(WITH_LIBAV "Use LibAV instead of FFmpeg" OFF)
|
||||
OPTION(BUILD_ANIMVIEWER "Build the animation viewer as part of the build process" OFF)
|
||||
IF(MSVC)
|
||||
OPTION(WITH_VLD "Build with Visual Leak Detector for Visual Studio" OFF)
|
||||
ENDIF(MSVC)
|
||||
option(WITH_SDL "Activate SDL Renderer" ON) # our default option
|
||||
option(WITH_AUDIO "Activate Sound" ON) # enabled by default
|
||||
option(WITH_MOVIES "Activate in game movies" ON)
|
||||
option(WITH_FREETYPE2 "Enhanced Font Support" ON)
|
||||
option(WITH_LUAJIT "Use LuaJIT instead of Lua" OFF)
|
||||
option(WITH_LIBAV "Use LibAV instead of FFmpeg" OFF)
|
||||
option(BUILD_ANIMVIEWER "Build the animation viewer as part of the build process" OFF)
|
||||
if(MSVC)
|
||||
option(WITH_VLD "Build with Visual Leak Detector for Visual Studio" OFF)
|
||||
endif()
|
||||
|
||||
IF(WITH_AUDIO)
|
||||
SET(CORSIX_TH_USE_SDL_MIXER ON)
|
||||
MESSAGE("Note: SDL audio is enabled (default)")
|
||||
ELSE()
|
||||
SET(CORSIX_TH_USE_SDL_MIXER OFF)
|
||||
MESSAGE("Note: SDL audio is disabled")
|
||||
ENDIF(WITH_AUDIO)
|
||||
if(WITH_AUDIO)
|
||||
set(CORSIX_TH_USE_SDL_MIXER ON)
|
||||
message("Note: SDL audio is enabled (default)")
|
||||
else()
|
||||
set(CORSIX_TH_USE_SDL_MIXER OFF)
|
||||
message("Note: SDL audio is disabled")
|
||||
endif()
|
||||
|
||||
IF(WITH_MOVIES)
|
||||
IF(WITH_AUDIO)
|
||||
IF(WITH_LIBAV)
|
||||
SET(CORSIX_TH_USE_FFMPEG OFF)
|
||||
SET(CORSIX_TH_USE_LIBAV ON)
|
||||
MESSAGE("Note: LibAV video is enabled")
|
||||
ELSE()
|
||||
SET(CORSIX_TH_USE_FFMPEG ON)
|
||||
SET(CORSIX_TH_USE_LIBAV OFF)
|
||||
MESSAGE("Note: FFMPEG video is enabled (default)")
|
||||
ENDIF(WITH_LIBAV)
|
||||
ELSE()
|
||||
SET(CORSIX_TH_USE_FFMPEG OFF)
|
||||
SET(CORSIX_TH_USE_LIBAV OFF)
|
||||
MESSAGE("Note: FFMPEG video disabled since it requires SDL audio.")
|
||||
ENDIF(WITH_AUDIO)
|
||||
ELSE()
|
||||
SET(CORSIX_TH_USE_FFMPEG OFF)
|
||||
SET(CORSIX_TH_USE_LIBAV OFF)
|
||||
MESSAGE("Note: FFMPEG video is disabled")
|
||||
ENDIF(WITH_MOVIES)
|
||||
if(WITH_MOVIES)
|
||||
if(WITH_AUDIO)
|
||||
if(WITH_LIBAV)
|
||||
set(CORSIX_TH_USE_FFMPEG OFF)
|
||||
set(CORSIX_TH_USE_LIBAV ON)
|
||||
message("Note: LibAV video is enabled")
|
||||
else()
|
||||
set(CORSIX_TH_USE_FFMPEG ON)
|
||||
set(CORSIX_TH_USE_LIBAV OFF)
|
||||
message("Note: FFMPEG video is enabled (default)")
|
||||
endif()
|
||||
else()
|
||||
set(CORSIX_TH_USE_FFMPEG OFF)
|
||||
set(CORSIX_TH_USE_LIBAV OFF)
|
||||
message("Note: FFMPEG video disabled since it requires SDL audio.")
|
||||
endif()
|
||||
else()
|
||||
set(CORSIX_TH_USE_FFMPEG OFF)
|
||||
set(CORSIX_TH_USE_LIBAV OFF)
|
||||
message("Note: FFMPEG video is disabled")
|
||||
endif()
|
||||
|
||||
IF(WITH_FREETYPE2)
|
||||
SET(CORSIX_TH_USE_FREETYPE2 ON)
|
||||
MESSAGE("Note: FreeType2 is enabled (default)")
|
||||
ELSE()
|
||||
SET(CORSIX_TH_USE_FREETYPE2 OFF)
|
||||
MESSAGE("Note: FreeType2 is disabled")
|
||||
ENDIF(WITH_FREETYPE2)
|
||||
if(WITH_FREETYPE2)
|
||||
set(CORSIX_TH_USE_FREETYPE2 ON)
|
||||
message("Note: FreeType2 is enabled (default)")
|
||||
else()
|
||||
set(CORSIX_TH_USE_FREETYPE2 OFF)
|
||||
message("Note: FreeType2 is disabled")
|
||||
endif()
|
||||
|
||||
IF(MSVC)
|
||||
IF(WITH_VLD)
|
||||
SET(CORSIX_TH_USE_VLD ON)
|
||||
MESSAGE("Note: Visual Leak Detector is enabled")
|
||||
ELSE()
|
||||
SET(CORSIX_TH_USE_VLD OFF)
|
||||
MESSAGE("Note: Visual Leak Detector is disabled (default)")
|
||||
ENDIF(WITH_VLD)
|
||||
ELSE()
|
||||
SET(CORSIX_TH_USE_VLD OFF)
|
||||
ENDIF(MSVC)
|
||||
if(MSVC)
|
||||
if(WITH_VLD)
|
||||
set(CORSIX_TH_USE_VLD ON)
|
||||
message("Note: Visual Leak Detector is enabled")
|
||||
else()
|
||||
set(CORSIX_TH_USE_VLD OFF)
|
||||
message("Note: Visual Leak Detector is disabled (default)")
|
||||
endif()
|
||||
else()
|
||||
set(CORSIX_TH_USE_VLD OFF)
|
||||
endif()
|
||||
|
||||
# Get precompiled dependencies before running the various find modules
|
||||
if ( USE_PRECOMPILED_DEPS )
|
||||
if(USE_PRECOMPILED_DEPS)
|
||||
message("Note: Using precompiled dependencies.")
|
||||
include( PrecompiledDeps )
|
||||
include(PrecompiledDeps)
|
||||
endif()
|
||||
|
||||
# Environment handling
|
||||
CHECK_INCLUDE_FILES(inttypes.h CORSIX_TH_HAS_INTTYPES_H)
|
||||
check_include_files(inttypes.h CORSIX_TH_HAS_INTTYPES_H)
|
||||
|
||||
# Include individual projects
|
||||
message("")
|
||||
@@ -123,21 +125,21 @@ message("")
|
||||
message("Building CorsixTH")
|
||||
add_subdirectory(CorsixTH)
|
||||
|
||||
IF(BUILD_ANIMVIEWER)
|
||||
if(BUILD_ANIMVIEWER)
|
||||
message("Building AnimView")
|
||||
add_subdirectory(AnimView)
|
||||
ENDIF(BUILD_ANIMVIEWER)
|
||||
endif()
|
||||
|
||||
# Documentation generation, construct 'doc' target (or a message it is disabled).
|
||||
|
||||
# Try to find 'lua'
|
||||
IF (WITH_LUAJIT)
|
||||
SET (LUA_PROGRAM_NAMES luajit-2.0.3 luajit)
|
||||
ELSE (WITH_LUAJIT)
|
||||
SET (LUA_PROGRAM_NAMES lua53 lua5.3 lua-5.3 lua52 lua5.2 lua-5.2 lua51 lua5.1 lua-5.1 lua)
|
||||
ENDIF(WITH_LUAJIT)
|
||||
if(WITH_LUAJIT)
|
||||
set(LUA_PROGRAM_NAMES luajit-2.0.3 luajit)
|
||||
else()
|
||||
set(LUA_PROGRAM_NAMES lua53 lua5.3 lua-5.3 lua52 lua5.2 lua-5.2 lua51 lua5.1 lua-5.1 lua)
|
||||
endif()
|
||||
|
||||
find_program (LUA_PROGRAM_PATH ${LUA_PROGRAM_NAMES}
|
||||
find_program(LUA_PROGRAM_PATH ${LUA_PROGRAM_NAMES}
|
||||
PATHS
|
||||
ENV LUA_DIR
|
||||
/opt
|
||||
@@ -147,27 +149,24 @@ find_program (LUA_PROGRAM_PATH ${LUA_PROGRAM_NAMES}
|
||||
/Library/Frameworks
|
||||
)
|
||||
|
||||
IF (LUA_PROGRAM_PATH)
|
||||
SET(LUA_PROGRAM_FOUND TRUE)
|
||||
ELSE (LUA_PROGRAM_PATH)
|
||||
SET(LUA_PROGRAM_FOUND FALSE)
|
||||
ENDIF (LUA_PROGRAM_PATH)
|
||||
if(LUA_PROGRAM_PATH)
|
||||
set(LUA_PROGRAM_FOUND TRUE)
|
||||
else()
|
||||
set(LUA_PROGRAM_FOUND FALSE)
|
||||
endif()
|
||||
|
||||
# Find doxygen.
|
||||
find_package(Doxygen)
|
||||
|
||||
# Generate build targets and the doc/index.html file.
|
||||
IF (DOXYGEN_FOUND OR LUA_PROGRAM_FOUND)
|
||||
if(DOXYGEN_FOUND OR LUA_PROGRAM_FOUND)
|
||||
add_custom_target(doc)
|
||||
|
||||
ELSE (DOXYGEN_FOUND OR LUA_PROGRAM_FOUND)
|
||||
else()
|
||||
message("Cannot locate Doxygen or lua, 'doc' target is not available")
|
||||
|
||||
ENDIF (DOXYGEN_FOUND OR LUA_PROGRAM_FOUND)
|
||||
|
||||
endif()
|
||||
|
||||
# Add sub-targets of the 'doc' target.
|
||||
IF (DOXYGEN_FOUND)
|
||||
if(DOXYGEN_FOUND)
|
||||
add_custom_target(doc_animview
|
||||
${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/DoxyGen/animview.doxygen
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/doc
|
||||
@@ -175,7 +174,6 @@ IF (DOXYGEN_FOUND)
|
||||
)
|
||||
add_dependencies(doc doc_animview)
|
||||
|
||||
|
||||
add_custom_target(doc_leveledit
|
||||
${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/DoxyGen/leveledit.doxygen
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/doc
|
||||
@@ -183,16 +181,15 @@ IF (DOXYGEN_FOUND)
|
||||
)
|
||||
add_dependencies(doc doc_leveledit)
|
||||
|
||||
|
||||
add_custom_target(doc_corsixth_engine
|
||||
${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/DoxyGen/corsixth_engine.doxygen
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/doc
|
||||
COMMENT "Generating API documentation for corsixth_engine" VERBATIM
|
||||
)
|
||||
add_dependencies(doc doc_corsixth_engine)
|
||||
ENDIF (DOXYGEN_FOUND)
|
||||
endif()
|
||||
|
||||
IF (LUA_PROGRAM_FOUND)
|
||||
if(LUA_PROGRAM_FOUND)
|
||||
add_custom_target(doc_corsixth_lua
|
||||
${LUA_PROGRAM_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/LDocGen/main.lua
|
||||
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/LDocGen/output/corner_right.gif ${CMAKE_CURRENT_BINARY_DIR}/doc/corsixth_lua
|
||||
@@ -202,35 +199,35 @@ IF (LUA_PROGRAM_FOUND)
|
||||
COMMENT "Generating API documentation for corsixth_lua" VERBATIM
|
||||
)
|
||||
add_dependencies(doc doc_corsixth_lua)
|
||||
ENDIF (LUA_PROGRAM_FOUND)
|
||||
endif()
|
||||
|
||||
# Generate doc/index.html file.
|
||||
IF (DOXYGEN_FOUND OR LUA_PROGRAM_FOUND)
|
||||
if(DOXYGEN_FOUND OR LUA_PROGRAM_FOUND)
|
||||
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/doc/index.html "<html>\n")
|
||||
file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/doc/index.html "<head><title>CorsixTH source code documentation</title></head>\n")
|
||||
file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/doc/index.html "<body>\n")
|
||||
file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/doc/index.html "<h1>CorsixTH main program source code documentation</h1>\n")
|
||||
file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/doc/index.html "<ul>\n")
|
||||
ENDIF (DOXYGEN_FOUND OR LUA_PROGRAM_FOUND)
|
||||
endif()
|
||||
|
||||
IF (DOXYGEN_FOUND)
|
||||
if(DOXYGEN_FOUND)
|
||||
file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/doc/index.html " <li><a href=\"corsixth_engine/html/index.html\">CorsixTH engine documentation</a>\n")
|
||||
ENDIF (DOXYGEN_FOUND)
|
||||
endif()
|
||||
|
||||
IF (LUA_PROGRAM_FOUND)
|
||||
if(LUA_PROGRAM_FOUND)
|
||||
file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/doc/index.html " <li><a href=\"corsixth_lua/index.html\">CorsixTH Lua documentation</a>\n")
|
||||
ENDIF (LUA_PROGRAM_FOUND)
|
||||
endif()
|
||||
|
||||
IF (DOXYGEN_FOUND)
|
||||
if(DOXYGEN_FOUND)
|
||||
file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/doc/index.html "</ul>\n")
|
||||
file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/doc/index.html "<h1>CorsixTH helper programs source code documentation</h1>\n")
|
||||
file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/doc/index.html "<ul>\n")
|
||||
file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/doc/index.html " <li><a href=\"animview/html/index.html\">Animation viewer documentation</a>\n")
|
||||
file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/doc/index.html " <li><a href=\"leveledit/html/index.html\">Level editor documentation</a>\n")
|
||||
ENDIF (DOXYGEN_FOUND)
|
||||
endif()
|
||||
|
||||
IF (DOXYGEN_FOUND OR LUA_PROGRAM_FOUND)
|
||||
if(DOXYGEN_FOUND OR LUA_PROGRAM_FOUND)
|
||||
file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/doc/index.html "</ul>\n")
|
||||
file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/doc/index.html "</body>\n")
|
||||
file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/doc/index.html "</html>\n")
|
||||
ENDIF (DOXYGEN_FOUND OR LUA_PROGRAM_FOUND)
|
||||
endif()
|
||||
|
@@ -1,45 +1,45 @@
|
||||
# Sanity check
|
||||
IF(CORSIX_TH_DONE_TOP_LEVEL_CMAKE)
|
||||
ELSE(CORSIX_TH_DONE_TOP_LEVEL_CMAKE)
|
||||
message(FATAL_ERROR "Please run cmake on the top-level directory, not this one.")
|
||||
ENDIF(CORSIX_TH_DONE_TOP_LEVEL_CMAKE)
|
||||
if(CORSIX_TH_DONE_TOP_LEVEL_CMAKE)
|
||||
else()
|
||||
message(FATAL_ERROR "Please run cmake on the top-level directory, not this one.")
|
||||
endif()
|
||||
|
||||
# Project Declaration
|
||||
PROJECT(CorsixTH)
|
||||
project(CorsixTH)
|
||||
|
||||
# Basic platform dependent stuff
|
||||
IF(UNIX)
|
||||
IF(APPLE)
|
||||
if(UNIX)
|
||||
if(APPLE)
|
||||
# fruit goes here
|
||||
add_subdirectory(SDLMain)
|
||||
ELSE(APPLE)
|
||||
else()
|
||||
# regular unix/linux
|
||||
ENDIF(APPLE)
|
||||
ELSE()
|
||||
IF(WIN32)
|
||||
endif()
|
||||
else()
|
||||
if(WIN32)
|
||||
# Win32 specific
|
||||
IF(MSVC)
|
||||
if(MSVC)
|
||||
# We want to bind against the very latest versions of the MSVC runtimes
|
||||
add_definitions(/D "_BIND_TO_CURRENT_VCLIBS_VERSION=1")
|
||||
ELSE(MSVC)
|
||||
IF(MSYS)
|
||||
else()
|
||||
if(MSYS)
|
||||
# MSYS stuff
|
||||
ELSE(MSYS)
|
||||
else()
|
||||
# What's left? MINGW? CYGWIN? BORLAND?
|
||||
ENDIF(MSYS)
|
||||
ENDIF(MSVC)
|
||||
ELSE(WIN32)
|
||||
endif()
|
||||
endif()
|
||||
else()
|
||||
# other OS (not UNIX, not 32/64 bit Windows)
|
||||
ENDIF(WIN32)
|
||||
ENDIF(UNIX)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Modify the config.h based upon our selection of options
|
||||
CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/CorsixTH/Src/config.h.in ${CMAKE_BINARY_DIR}/CorsixTH/Src/config.h)
|
||||
INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR}/CorsixTH/Src/)
|
||||
configure_file(${CMAKE_SOURCE_DIR}/CorsixTH/Src/config.h.in ${CMAKE_BINARY_DIR}/CorsixTH/Src/config.h)
|
||||
include_directories(${CMAKE_BINARY_DIR}/CorsixTH/Src/)
|
||||
|
||||
# Generate source files list
|
||||
# Note: Done after generating config.h
|
||||
FILE(GLOB_RECURSE corsixth_source_files
|
||||
file(GLOB_RECURSE corsixth_source_files
|
||||
${CMAKE_SOURCE_DIR}/CorsixTH/SrcUnshared/*.cpp
|
||||
${CMAKE_SOURCE_DIR}/CorsixTH/SrcUnshared/*.c
|
||||
${CMAKE_SOURCE_DIR}/CorsixTH/SrcUnshared/*.h
|
||||
@@ -57,7 +57,7 @@ FILE(GLOB_RECURSE corsixth_source_files
|
||||
)
|
||||
|
||||
# Declaration of the executable
|
||||
IF(APPLE)
|
||||
if(APPLE)
|
||||
add_definitions(-DIS_CORSIXTH_APP)
|
||||
|
||||
set(corsixth_icon_file ${CMAKE_SOURCE_DIR}/CorsixTH/Icon.icns)
|
||||
@@ -77,141 +77,143 @@ IF(APPLE)
|
||||
add_custom_command(TARGET CorsixTH
|
||||
POST_BUILD
|
||||
COMMAND rsync -rv --include-from ${CMAKE_SOURCE_DIR}/CorsixTH/RequiredResources.txt ${CMAKE_SOURCE_DIR}/CorsixTH/ \${TARGET_BUILD_DIR}/\${FULL_PRODUCT_NAME}/Contents/MacOS
|
||||
COMMAND rsync -rv ${CMAKE_SOURCE_DIR}/CorsixTH/Icon.icns \${TARGET_BUILD_DIR}/\${FULL_PRODUCT_NAME}/Contents/Resources/)
|
||||
COMMAND rsync -rv ${CMAKE_SOURCE_DIR}/CorsixTH/Icon.icns \${TARGET_BUILD_DIR}/\${FULL_PRODUCT_NAME}/Contents/Resources/
|
||||
)
|
||||
|
||||
target_link_libraries(CorsixTH SDL2main)
|
||||
INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR}/CorsixTH/SDLMain/)
|
||||
ELSE()
|
||||
include_directories(${CMAKE_BINARY_DIR}/CorsixTH/SDLMain/)
|
||||
else()
|
||||
add_executable(CorsixTH ${corsixth_source_files})
|
||||
ENDIF()
|
||||
endif()
|
||||
|
||||
# Add an extra step to copy built DLLs on MSVC
|
||||
IF(USE_VCPKG_DEPS)
|
||||
INCLUDE(CopyVcpkgLua)
|
||||
if(USE_VCPKG_DEPS)
|
||||
include(CopyVcpkgLua)
|
||||
ENDIF()
|
||||
|
||||
# Finding libraries
|
||||
## Finding libraries
|
||||
|
||||
# Find SDL
|
||||
IF (MSVC AND USE_VCPKG_DEPS)
|
||||
FIND_PACKAGE(SDL2 CONFIG REQUIRED)
|
||||
TARGET_LINK_LIBRARIES(CorsixTH SDL2::SDL2)
|
||||
TARGET_LINK_LIBRARIES(CorsixTH SDL2::SDL2main)
|
||||
ELSE()
|
||||
FIND_PACKAGE(SDL2 REQUIRED)
|
||||
IF(SDL_FOUND)
|
||||
INCLUDE_DIRECTORIES(${SDL_INCLUDE_DIR})
|
||||
IF(SDLMAIN_LIBRARY STREQUAL "")
|
||||
if(MSVC AND USE_VCPKG_DEPS)
|
||||
find_package(SDL2 CONFIG REQUIRED)
|
||||
target_link_libraries(CorsixTH SDL2::SDL2)
|
||||
target_link_libraries(CorsixTH SDL2::SDL2main)
|
||||
else()
|
||||
find_package(SDL2 REQUIRED)
|
||||
if(SDL_FOUND)
|
||||
include_directories(${SDL_INCLUDE_DIR})
|
||||
if(SDLMAIN_LIBRARY STREQUAL "")
|
||||
message(FATAL_ERROR "Error: SDL was found but SDLmain was not")
|
||||
message("Make sure the path is correctly defined or set the environment variable SDLDIR to the correct location")
|
||||
ENDIF(SDLMAIN_LIBRARY STREQUAL "")
|
||||
endif()
|
||||
# No need to specify sdlmain separately, the FindSDL.cmake file will take care of that. If not we get an error about it
|
||||
TARGET_LINK_LIBRARIES(CorsixTH ${SDL_LIBRARY})
|
||||
target_link_libraries(CorsixTH ${SDL_LIBRARY})
|
||||
message(" SDL found")
|
||||
ELSE(SDL_FOUND)
|
||||
else()
|
||||
message(FATAL_ERROR "Error: SDL library not found, it is required to build. Make sure the path is correctly defined or set the environment variable SDLDIR to the correct location")
|
||||
ENDIF(SDL_FOUND)
|
||||
ENDIF()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Find Lua
|
||||
FIND_PACKAGE(Lua REQUIRED)
|
||||
IF(Lua_FOUND)
|
||||
TARGET_LINK_LIBRARIES(CorsixTH ${LUA_LIBRARY})
|
||||
INCLUDE_DIRECTORIES(${LUA_INCLUDE_DIR})
|
||||
find_package(Lua REQUIRED)
|
||||
if(Lua_FOUND)
|
||||
target_link_libraries(CorsixTH ${LUA_LIBRARY})
|
||||
include_directories(${LUA_INCLUDE_DIR})
|
||||
# Special link flags needed on OSX/64bit, according to: http://luajit.org/install.html
|
||||
# If these are not specified, luaL_newstate() returns NULL and we get this:
|
||||
# Fatal error starting CorsixTH: Cannot open Lua state.
|
||||
IF(${CMAKE_SYSTEM_NAME} MATCHES "Darwin" AND LUA_INTERPRETER_TYPE STREQUAL "LuaJIT" AND CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||
TARGET_LINK_LIBRARIES(CorsixTH "-pagezero_size 10000" "-image_base 100000000")
|
||||
ENDIF()
|
||||
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin" AND LUA_INTERPRETER_TYPE STREQUAL "LuaJIT" AND CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||
target_link_libraries(CorsixTH "-pagezero_size 10000" "-image_base 100000000")
|
||||
endif()
|
||||
message(" ${LUA_INTERPRETER_TYPE} found")
|
||||
ELSE(Lua_FOUND)
|
||||
else()
|
||||
message(FATAL_ERROR "Error: Lua library not found, it is required to build")
|
||||
ENDIF(Lua_FOUND)
|
||||
endif()
|
||||
|
||||
# Add threading library
|
||||
find_package(Threads)
|
||||
target_link_libraries(CorsixTH ${CMAKE_THREAD_LIBS_INIT})
|
||||
|
||||
# Find SDL_mixer
|
||||
IF(CORSIX_TH_USE_SDL_MIXER)
|
||||
FIND_PACKAGE(SDL2_mixer REQUIRED)
|
||||
IF(SDLMIXER_FOUND)
|
||||
TARGET_LINK_LIBRARIES(CorsixTH ${SDLMIXER_LIBRARY})
|
||||
INCLUDE_DIRECTORIES(${SDLMIXER_INCLUDE_DIR})
|
||||
if(CORSIX_TH_USE_SDL_MIXER)
|
||||
find_package(SDL2_mixer REQUIRED)
|
||||
if(SDLMIXER_FOUND)
|
||||
target_link_libraries(CorsixTH ${SDLMIXER_LIBRARY})
|
||||
include_directories(${SDLMIXER_INCLUDE_DIR})
|
||||
message(" SDL_mixer found")
|
||||
ELSE(SDLMIXER_FOUND)
|
||||
else()
|
||||
message(FATAL_ERROR "Error: SDL_mixer library not found, even though it was selected to be included")
|
||||
ENDIF(SDLMIXER_FOUND)
|
||||
ENDIF(CORSIX_TH_USE_SDL_MIXER)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
message( STATUS "CMAKE_MODULE_PATH=${CMAKE_MODULE_PATH}" )
|
||||
message(STATUS "CMAKE_MODULE_PATH=${CMAKE_MODULE_PATH}")
|
||||
|
||||
# Find FFMPEG
|
||||
IF(CORSIX_TH_USE_FFMPEG)
|
||||
FIND_PACKAGE(FFmpeg COMPONENTS AVFORMAT AVCODEC AVUTIL SWSCALE SWRESAMPLE REQUIRED)
|
||||
IF(FFMPEG_FOUND)
|
||||
TARGET_LINK_LIBRARIES(CorsixTH ${FFMPEG_LIBRARIES})
|
||||
INCLUDE_DIRECTORIES(${FFMPEG_INCLUDE_DIRS})
|
||||
IF(APPLE)
|
||||
TARGET_LINK_LIBRARIES(CorsixTH libz.dylib)
|
||||
ENDIF()
|
||||
if(CORSIX_TH_USE_FFMPEG)
|
||||
find_package(FFmpeg COMPONENTS AVFORMAT AVCODEC AVUTIL SWSCALE SWRESAMPLE REQUIRED)
|
||||
if(FFMPEG_FOUND)
|
||||
target_link_libraries(CorsixTH ${FFMPEG_LIBRARIES})
|
||||
include_directories(${FFMPEG_INCLUDE_DIRS})
|
||||
if(APPLE)
|
||||
target_link_libraries(CorsixTH libz.dylib)
|
||||
endif()
|
||||
message(" FFmpeg found")
|
||||
ELSE(FFMPEG_FOUND)
|
||||
else()
|
||||
message(FATAL_ERROR "Error: FFmpeg library not found, even though it was selected to be included")
|
||||
ENDIF(FFMPEG_FOUND)
|
||||
ENDIF(CORSIX_TH_USE_FFMPEG)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
IF(CORSIX_TH_USE_LIBAV)
|
||||
FIND_PACKAGE(LibAV COMPONENTS AVFORMAT AVCODEC AVRESAMPLE AVUTIL SWSCALE REQUIRED)
|
||||
IF(LIBAV_FOUND)
|
||||
TARGET_LINK_LIBRARIES(CorsixTH ${LIBAV_LIBRARIES})
|
||||
INCLUDE_DIRECTORIES(${LIBAV_INCLUDE_DIRS})
|
||||
IF(APPLE)
|
||||
TARGET_LINK_LIBRARIES(CorsixTH libz.dylib)
|
||||
ENDIF()
|
||||
if(CORSIX_TH_USE_LIBAV)
|
||||
find_package(LibAV COMPONENTS AVFORMAT AVCODEC AVRESAMPLE AVUTIL SWSCALE REQUIRED)
|
||||
if(LIBAV_FOUND)
|
||||
target_link_libraries(CorsixTH ${LIBAV_LIBRARIES})
|
||||
include_directories(${LIBAV_INCLUDE_DIRS})
|
||||
if(APPLE)
|
||||
target_link_libraries(CorsixTH libz.dylib)
|
||||
endif()
|
||||
message(" LibAV found")
|
||||
ELSE(LIBAV_FOUND)
|
||||
else()
|
||||
message(FATAL_ERROR "Error: LibAV library not found, even though it was selected to be included")
|
||||
ENDIF(LIBAV_FOUND)
|
||||
ENDIF(CORSIX_TH_USE_LIBAV)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Find Freetype2
|
||||
IF(CORSIX_TH_USE_FREETYPE2)
|
||||
FIND_PACKAGE(Freetype REQUIRED)
|
||||
IF(FREETYPE_FOUND)
|
||||
TARGET_LINK_LIBRARIES(CorsixTH ${FREETYPE_LIBRARIES})
|
||||
INCLUDE_DIRECTORIES(${FREETYPE_INCLUDE_DIRS})
|
||||
IF(APPLE)
|
||||
TARGET_LINK_LIBRARIES(CorsixTH libz.dylib)
|
||||
TARGET_LINK_LIBRARIES(CorsixTH libbz2.dylib)
|
||||
ENDIF()
|
||||
if(CORSIX_TH_USE_FREETYPE2)
|
||||
find_package(Freetype REQUIRED)
|
||||
if(FREETYPE_FOUND)
|
||||
target_link_libraries(CorsixTH ${FREETYPE_LIBRARIES})
|
||||
include_directories(${FREETYPE_INCLUDE_DIRS})
|
||||
if(APPLE)
|
||||
target_link_libraries(CorsixTH libz.dylib)
|
||||
target_link_libraries(CorsixTH libbz2.dylib)
|
||||
endif()
|
||||
message(" FreeType2 found")
|
||||
ELSE(FREETYPE_FOUND)
|
||||
else()
|
||||
message(FATAL_ERROR "Error: FreeType2 library not found, even though it was selected to be used")
|
||||
ENDIF(FREETYPE_FOUND)
|
||||
ENDIF(CORSIX_TH_USE_FREETYPE2)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Find msinttypes for MSVC
|
||||
IF(MSVC AND NOT CORSIX_TH_HAS_INTTYPES_H)
|
||||
FIND_PATH(MSINTTYPES_INCLUDE_DIRS "inttypes.h" NO_DEFAULT_PATH)
|
||||
MESSAGE(STATUS "Adding include directory: ${MSINTTYPES_INCLUDE_DIRS}")
|
||||
INCLUDE_DIRECTORIES(${MSINTTYPES_INCLUDE_DIRS})
|
||||
SET(CORSIX_TH_HAS_INTTYPES_H 1)
|
||||
ENDIF(MSVC AND NOT CORSIX_TH_HAS_INTTYPES_H)
|
||||
if(MSVC AND NOT CORSIX_TH_HAS_INTTYPES_H)
|
||||
find_path(MSINTTYPES_INCLUDE_DIRS "inttypes.h" NO_DEFAULT_PATH)
|
||||
message(STATUS "Adding include directory: ${MSINTTYPES_INCLUDE_DIRS}")
|
||||
include_directories(${MSINTTYPES_INCLUDE_DIRS})
|
||||
set(CORSIX_TH_HAS_INTTYPES_H 1)
|
||||
endif()
|
||||
|
||||
IF(MSVC AND CORSIX_TH_USE_VLD)
|
||||
FIND_PACKAGE(VLD REQUIRED)
|
||||
IF(VLD_FOUND)
|
||||
TARGET_LINK_LIBRARIES(CorsixTH ${VLD_LIBRARY})
|
||||
INCLUDE_DIRECTORIES(CorsixTH ${VLD_INCLUDE_DIR})
|
||||
if(MSVC AND CORSIX_TH_USE_VLD)
|
||||
find_package(VLD REQUIRED)
|
||||
if(VLD_FOUND)
|
||||
target_link_libraries(CorsixTH ${VLD_LIBRARY})
|
||||
include_directories(CorsixTH ${VLD_INCLUDE_DIR})
|
||||
message(" VLD found")
|
||||
ELSE(VLD_FOUND)
|
||||
else()
|
||||
message(FATAL_ERROR "Error: VLD Library not found, it is required to build when USE_VLD is set")
|
||||
ENDIF(VLD_FOUND)
|
||||
ENDIF(MSVC AND CORSIX_TH_USE_VLD)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Declaration of the install process
|
||||
IF(APPLE)
|
||||
if(APPLE)
|
||||
#Just use the prefix as it's sufficient to just set the prefix to /Applications on Mac.
|
||||
install(TARGETS CorsixTH BUNDLE DESTINATION .)
|
||||
|
||||
@@ -221,11 +223,12 @@ IF(APPLE)
|
||||
SET(BU_CHMOD_BUNDLE_ITEMS ON)
|
||||
FIXUP_BUNDLE(${CMAKE_INSTALL_PREFIX}/CorsixTH.app \"\" \"\")
|
||||
")
|
||||
ELSE()
|
||||
else()
|
||||
install(TARGETS CorsixTH RUNTIME DESTINATION CorsixTH)
|
||||
install(DIRECTORY Campaigns Lua Levels DESTINATION CorsixTH PATTERN "*.svn" EXCLUDE)
|
||||
install(DIRECTORY Bitmap DESTINATION CorsixTH
|
||||
FILES_MATCHING REGEX ".*\\.(tab|pal|dat|png)$"
|
||||
PATTERN "*.svn" EXCLUDE)
|
||||
PATTERN "*.svn" EXCLUDE
|
||||
)
|
||||
install(FILES CorsixTH.lua ../LICENSE.txt CorsixTH.ico DESTINATION CorsixTH )
|
||||
ENDIF()
|
||||
endif()
|
||||
|
@@ -1,8 +1,6 @@
|
||||
IF(APPLE)
|
||||
if(APPLE)
|
||||
find_package(SDL2 REQUIRED)
|
||||
|
||||
set(CMAKE_OSX_ARCHITECTURES "x86_64")
|
||||
include_directories(${SDL_INCLUDE_DIR})
|
||||
|
||||
add_library (SDL2main STATIC SDLMain.m)
|
||||
endif(APPLE)
|
||||
endif()
|
||||
|
Reference in New Issue
Block a user