Commit 8439bab6 authored by DailyShana's avatar DailyShana

cmake

modified from ygopro2 branch
parent 25d24f28
project (ygo)
cmake_minimum_required (VERSION 2.8)
if(NOT CMAKE_BUILD_TYPE)
message(STATUS "Setting build type to 'Debug' as none was specified.")
set(CMAKE_BUILD_TYPE Debug CACHE STRING "Choose the type of build." FORCE)
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo")
endif()
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/macros")
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
include (AutoFiles)
include (platform/settings)
if (MSVC)
add_subdirectory (event)
add_subdirectory (freetype)
add_subdirectory (irrlicht)
add_subdirectory (sqlite3)
else ()
find_package(LibEvent REQUIRED)
find_package(Freetype REQUIRED)
find_package(Irrlicht REQUIRED)
find_package(Sqlite REQUIRED)
find_package(OpenGL REQUIRED)
endif ()
option(USE_IRRKLANG "Use irrKlang sound library" OFF)
if (USE_IRRKLANG)
set(IRRKLANG_DIR ${CMAKE_SOURCE_DIR}/irrKlang)
endif ()
add_subdirectory (lua)
add_subdirectory (ocgcore)
add_subdirectory (gframe)
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14")
set (CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -D_DEBUG")
set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_DEBUG")
add_definitions ( "-Wall" "-fexceptions" "-fomit-frame-pointer" "-fno-strict-aliasing" "-Wno-multichar" )
add_definitions ( "-static-libgcc" "-static-libstdc++" )
add_definitions ( "-wd4996" "-D_CRT_SECURE_NO_WARNINGS" "-D_ITERATOR_DEBUG_LEVEL=0" )
add_definitions ( "-D_UNICODE" "-DUNICODE" "/utf-8" )
include (MSVCMultipleProcessCompile)
include (MSVCStaticRuntime)
function (AutoFiles _folder _base _pattern)
if (ARGC GREATER 3)
set(_exclude ${ARGN})
else ()
set(_exclude)
endif ()
file (GLOB _files RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}/ ${_folder}/*)
set (folderFiles)
foreach (_fname ${_files})
if (IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/${_fname})
AutoFiles ("${_fname}" "${_base}" "${_pattern}" "${_exclude}")
elseif (_fname MATCHES ${_pattern})
if(_exclude)
if (NOT _fname MATCHES ${_exclude})
set(folderFiles ${folderFiles} ${_fname})
endif ()
else ()
set(folderFiles ${folderFiles} ${_fname})
endif ()
endif ()
endforeach ()
string(REPLACE "./" "" _folder2 ${_folder})
string(REPLACE "/" "\\" _folder2 ${_folder2})
if (_folder2 STREQUAL ".")
source_group(${_base} FILES ${folderFiles})
else ()
source_group(${_base}\\${_folder2} FILES ${folderFiles})
endif ()
set(AUTO_FILES_RESULT ${AUTO_FILES_RESULT} ${folderFiles} PARENT_SCOPE)
endfunction ()
# - Try to find the dl library
# Once done this will define
#
# DL_FOUND - System has libdl
# DL_LIBRARIES - The libraries needed to use libdl
# DL_DEFINITIONS - Compiler switches required for using libdl
FIND_PATH(DL_INCLUDE_DIR dlfcn.h
PATH_SUFFIXES include
PATHS
~/Library/Frameworks
/Library/Frameworks
/opt/local
)
FIND_LIBRARY(DL_LIBRARIES NAMES dl
PATH_SUFFIXES lib64 lib
PATHS
~/Library/Frameworks
/Library/Frameworks
/opt/local
)
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(libdl DEFAULT_MSG DL_LIBRARIES DL_INCLUDE_DIR)
MARK_AS_ADVANCED(DL_INCLUDE_DIR DL_LIBRARIES)
# - Try to find the Lib library
# Once done this will define
#
# FREETYPE_FOUND - System has freetype
# FREETYPE_INCLUDE_DIR - The freetype include directory
# FREETYPE_LIBRARIES - The libraries needed to use freetype
# FREETYPE_DEFINITIONS - Compiler switches required for using freetype
SET(FREETYPE_DEFINITIONS ${PC_FREETYPE_CFLAGS_OTHER})
FIND_PATH(FREETYPE_INCLUDE_DIR ft2build.h
HINTS
${PC_FREETYPE_INCLUDEDIR}
${PC_FREETYPE_INCLUDE_DIRS}
PATH_SUFFIXES freetype2
PATHS
~/Library/Frameworks
/Library/Frameworks
/opt/local
)
FIND_LIBRARY(FREETYPE_LIBRARIES NAMES freetype
HINTS
${PC_FREETYPE_LIBDIR}
${PC_FREETYPE_LIBRARY_DIRS}
PATH_SUFFIXES lib64 lib
PATHS
~/Library/Frameworks
/Library/Frameworks
/opt/local
)
SET(FREETYPE_LIBRARIES ${FREETYPE_LIBRARIES})
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(FREETYPE DEFAULT_MSG FREETYPE_LIBRARIES FREETYPE_INCLUDE_DIR)
MARK_AS_ADVANCED(FREETYPE_INCLUDE_DIR FREETYPE_LIBRARIES)
# - Try to find the Lib library
# Once done this will define
#
# IRRLICHT_FOUND - System has IRRLICHT
# IRRLICHT_INCLUDE_DIR - The IRRLICHT include directory
# IRRLICHT_LIBRARIES - The libraries needed to use IRRLICHT
# IRRLICHT_DEFINITIONS - Compiler switches required for using IRRLICHT
# use pkg-config to get the directories and then use these values
# in the FIND_PATH() and FIND_LIBRARY() calls
#FIND_PACKAGE(PkgConfig)
#PKG_SEARCH_MODULE(PC_IRRLICHT Irrlicht)
SET(IRRLICHT_DEFINITIONS ${PC_IRRLICHT_CFLAGS_OTHER})
FIND_PATH(IRRLICHT_INCLUDE_DIR irrlicht.h
HINTS
${PC_IRRLICHT_INCLUDEDIR}
${PC_IRRLICHT_INCLUDE_DIRS}
PATH_SUFFIXES include include/irrlicht
PATHS
~/Library/Frameworks
/Library/Frameworks
/opt/local
)
FIND_LIBRARY(IRRLICHT_LIBRARIES NAMES Irrlicht irrlicht
HINTS
${PC_IRRLICHT_LIBDIR}
${PC_IRRLICHT_LIBRARY_DIRS}
PATH_SUFFIXES lib64 lib
PATHS
~/Library/Frameworks
/Library/Frameworks
/opt/local
)
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Irrlicht DEFAULT_MSG IRRLICHT_LIBRARIES IRRLICHT_INCLUDE_DIR)
MARK_AS_ADVANCED(IRRLICHT_INCLUDE_DIR IRRLICHT_LIBRARIES)
# - Try to find the Lib library
# Once done this will define
#
# LIBEVENT_FOUND - System has Libevent
# LIBEVENT_INCLUDE_DIR - The Libevent include directory
# LIBEVENT_LIBRARIES - The libraries needed to use Libevent
# LIBEVENT_DEFINITIONS - Compiler switches required for using Libevent
# use pkg-config to get the directories and then use these values
# in the FIND_PATH() and FIND_LIBRARY() calls
#FIND_PACKAGE(PkgConfig)
#PKG_SEARCH_MODULE(PC_LIBEVENT event)
SET(LIBEVENT_DEFINITIONS ${PC_LIBEVENT_CFLAGS_OTHER})
FIND_PATH(LIBEVENT_INCLUDE_DIR event2/event.h
HINTS
${PC_LIBEVENT_INCLUDEDIR}
${PC_LIBEVENT_INCLUDE_DIRS}
PATH_SUFFIXES include
PATHS
~/Library/Frameworks
/Library/Frameworks
/opt/local
)
FIND_LIBRARY(LIBEVENT_LIBRARIES NAMES event
HINTS
${PC_LIBEVENT_LIBDIR}
${PC_LIBEVENT_LIBRARY_DIRS}
PATH_SUFFIXES lib64 lib
PATHS
~/Library/Frameworks
/Library/Frameworks
/opt/local
)
FIND_LIBRARY(LIBEVENT_LIBRARIES_PTHREADS NAMES event_pthreads
HINTS
${PC_LIBEVENT_LIBDIR}
${PC_LIBEVENT_LIBRARY_DIRS}
PATH_SUFFIXES lib64 lib
PATHS
~/Library/Frameworks
/Library/Frameworks
/opt/local
)
SET(LIBEVENT_LIBRARIES ${LIBEVENT_LIBRARIES} ${LIBEVENT_LIBRARIES_PTHREADS})
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(LibEvent DEFAULT_MSG LIBEVENT_LIBRARIES LIBEVENT_INCLUDE_DIR)
MARK_AS_ADVANCED(LIBEVENT_INCLUDE_DIR LIBEVENT_LIBRARIES)
# - Try to find the Lib library
# Once done this will define
#
# SQLITE_FOUND - System has sqlite
# SQLITE_INCLUDE_DIR - The sqlite include directory
# SQLITE_LIBRARIES - The libraries needed to use sqlite
# SQLITE_DEFINITIONS - Compiler switches required for using sqlite
SET(SQLITE_DEFINITIONS ${PC_SQLITE_CFLAGS_OTHER})
FIND_PATH(SQLITE_INCLUDE_DIR sqlite3.h
HINTS
${PC_SQLITE_INCLUDEDIR}
${PC_SQLITE_INCLUDE_DIRS}
PATH_SUFFIXES include
PATHS
~/Library/Frameworks
/Library/Frameworks
/opt/local
)
FIND_LIBRARY(SQLITE_LIBRARIES NAMES sqlite3
HINTS
${PC_SQLITE_LIBDIR}
${PC_SQLITE_LIBRARY_DIRS}
PATH_SUFFIXES lib64 lib
PATHS
~/Library/Frameworks
/Library/Frameworks
/opt/local
)
SET(SQLITE_LIBRARIES ${SQLITE_LIBRARIES})
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(SQLITE DEFAULT_MSG SQLITE_LIBRARIES SQLITE_INCLUDE_DIR)
MARK_AS_ADVANCED(SQLITE_INCLUDE_DIR SQLITE_LIBRARIES)
# - Combine lists of prefixes and suffixes in all combinations
#
# list_combinations(var PREFIXES listitems... SUFFIXES listitems...) -
# where var is the name of your desired output variable and PREFIXES
# and SUFFIXES are special arguments that indicate the start of your
# list of prefixes or suffixes respectively.
#
# Original Author:
# 2009-2010 Ryan Pavlik <rpavlik@iastate.edu> <abiryan@ryand.net>
# http://academic.cleardefinition.com
# Iowa State University HCI Graduate Program/VRAC
#
# Copyright Iowa State University 2009-2010.
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
if(__list_combinations)
return()
endif()
set(__list_combinations YES)
function(list_combinations var)
# Parse arguments
set(_prefixes)
set(_suffixes)
set(_nowhere)
set(_curdest _nowhere)
foreach(_element ${ARGN})
if("${_element}" STREQUAL "PREFIXES")
set(_curdest _prefixes)
elseif("${_element}" STREQUAL "SUFFIXES")
set(_curdest _suffixes)
else()
list(APPEND ${_curdest} "${_element}")
endif()
endforeach()
if(_nowhere)
message(STATUS "_prefixes ${_prefixes}")
message(STATUS "_prefixes ${_suffixes}")
message(STATUS "_prefixes ${_nowhere}")
message(FATAL_ERROR
"Syntax error in use of ${CMAKE_CURRENT_LIST_FILE}")
endif()
foreach(_prefix ${_prefixes})
foreach(_suffix ${_suffixes})
list(APPEND _out "${_prefix}${_suffix}")
endforeach()
endforeach()
set(${var} "${_out}" PARENT_SCOPE)
endfunction()
# - Compile with multiple processes on MSVC
#
# include(MSVCMultipleProcessCompile)
#
# Requires these CMake modules:
# ListCombinations.cmake
#
# Original Author:
# 2009-2010 Ryan Pavlik <rpavlik@iastate.edu> <abiryan@ryand.net>
# http://academic.cleardefinition.com
# Iowa State University HCI Graduate Program/VRAC
#
# Copyright Iowa State University 2009-2010.
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
if(MSVC AND NOT "${MSVC_VERSION}" LESS 1400)
# Only available in VS 2005 and newer
string(TOUPPER "${CMAKE_CONFIGURATION_TYPES}" _conftypesUC)
include(ListCombinations)
list_combinations(_varnames
PREFIXES
CMAKE_C_FLAGS_
CMAKE_CXX_FLAGS_
SUFFIXES
${_conftypesUC})
foreach(_var ${_varnames})
set(${_var} "${${_var}} /MP")
endforeach()
endif()
# - Modify compile flags to use the static runtimes of MSVC
#
# include(MSVCStaticRuntime)
#
# Requires these CMake modules:
# ListCombinations.cmake
#
# Original Author:
# 2009-2010 Ryan Pavlik <rpavlik@iastate.edu> <abiryan@ryand.net>
# http://academic.cleardefinition.com
# Iowa State University HCI Graduate Program/VRAC
#
# Copyright Iowa State University 2009-2010.
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
if(MSVC)
string(TOUPPER "${CMAKE_CONFIGURATION_TYPES}" _conftypesUC)
include(ListCombinations)
list_combinations(_varnames
PREFIXES
CMAKE_C_FLAGS_
CMAKE_CXX_FLAGS_
SUFFIXES
${_conftypesUC})
foreach(_var ${_varnames})
string(REPLACE "/MDd" "/MTd" ${_var} "${${_var}}")
string(REPLACE "/MD" "/MT" ${_var} "${${_var}}")
endforeach()
endif()
set(Boost_USE_STATIC_LIBS ON)
add_definitions ( "-DLUA_USE_MACOSX" )
add_definitions ( "-DLUA_USE_POSIX" )
add_definitions ( "-DLUA_USE_LINUX" )
if(CMAKE_SIZEOF_VOID_P MATCHES 8)
set(PLATFORM 64)
MESSAGE(STATUS "Detected 64-bit platform")
else()
set(PLATFORM 32)
MESSAGE(STATUS "Detected 32-bit platform")
endif()
if(WIN32)
include(platform/win)
elseif(UNIX)
include(platform/unix)
endif()
if (APPLE)
include (platform/apple)
if ("${CMAKE_GENERATOR}" MATCHES "Xcode")
include (platform/xcode)
endif ()
elseif (CMAKE_SYSTEM MATCHES Linux)
include (platform/linux)
else ()
include (platform/common)
endif ()
if(CMAKE_C_COMPILER MATCHES "icc")
include(compiler/icc)
elseif(CMAKE_C_COMPILER MATCHES "clang")
include(compiler/clang-compile)
elseif(CMAKE_C_COMPILER MATCHES "cc")
include(compiler/gcc)
endif()
find_package(Threads)
find_package(DL)
if ( MSVC )
include(compiler/msvc)
elseif ( MINGW )
if(CMAKE_C_COMPILER MATCHES "clang")
include(compiler/clang)
elseif(CMAKE_C_COMPILER MATCHES "cc")
include(compiler/gcc)
endif()
include(compiler/mingw)
endif()
set(CMAKE_XCODE_ATTRIBUTE_GCC_VERSION "com.apple.compilers.llvm.clang.1_0")
set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LANGUAGE_STANDARD "c++14")
set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY "libc++")
project (ygopro)
if (NOT WIN32 AND NOT APPLE)
include (FindX11)
endif ()
add_subdirectory (lzma)
set (AUTO_FILES_RESULT)
if (MSVC)
AutoFiles("." "res" "\\.(rc)$")
AutoFiles("." "src" "\\.(cpp|c|h)$" "CGUIButton.cpp|lzma/\\.*")
else ()
AutoFiles("." "src" "\\.(cpp|c|h)$" "lzma/\\.*")
endif ()
if (MSVC)
add_executable (ygopro WIN32 ${AUTO_FILES_RESULT})
set_target_properties (ygopro PROPERTIES LINK_FLAGS /ENTRY:"mainCRTStartup")
else ()
add_executable (ygopro ${AUTO_FILES_RESULT})
endif ()
target_link_libraries (ygopro ocgcore lua clzma)
if (MSVC)
target_link_libraries (ygopro irrlicht freetype sqlite3 event)
include_directories ( "../irrlicht/include" "../freetype/include" "../event/include" "../sqlite3" )
else ()
target_link_libraries (ygopro
${IRRLICHT_LIBRARIES}
${FREETYPE_LIBRARIES}
${SQLITE_LIBRARIES}
${LIBEVENT_LIBRARIES}
${OPENGL_gl_LIBRARY}
)
include_directories (
${IRRLICHT_INCLUDE_DIR}
${FREETYPE_INCLUDE_DIR}
${SQLITE_INCLUDE_DIRS}
${LIBEVENT_INCLUDE_DIR}
${OPENGL_INCLUDE_DIR}
)
target_link_libraries (ygopro ${CMAKE_THREAD_LIBS_INIT} ${DL_LIBRARIES})
endif ()
if (USE_IRRKLANG)
add_definitions ( "-DYGOPRO_USE_IRRKLANG" )
if (MSVC)
target_link_libraries (ygopro ${IRRKLANG_DIR}/lib/Win32-visualStudio/irrKlang.lib)
elseif (CMAKE_SYSTEM MATCHES Linux)
target_link_libraries (ygopro ${IRRKLANG_DIR}/bin/linux-gcc-64/libIrrKlang.so)
endif ()
include_directories ( "${IRRKLANG_DIR}/include" )
endif ()
if (WIN32)
target_link_libraries (ygopro ws2_32 winmm gdi32 kernel32 user32 imm32 opengl32)
endif ()
project (clzma)
set (AUTO_FILES_RESULT)
AutoFiles("." "src" "\\.(cpp|c|h)$")
add_library (clzma STATIC ${AUTO_FILES_RESULT})
project (lua)
set (AUTO_FILES_RESULT)
AutoFiles("." "src" "\\.(cpp|c|h)$" "lua.c|luac.c")
set_source_files_properties(${AUTO_FILES_RESULT} PROPERTIES LANGUAGE CXX)
add_library (lua STATIC ${AUTO_FILES_RESULT})
Subproject commit 3c4fd547c47e0e2c73b0b7bcee0c9bd6210476b8 Subproject commit 4382ead1023b7e3109e9f24e3dbf4ddf61f3e986
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment