Skip to content

Commit

Permalink
cmake
Browse files Browse the repository at this point in the history
modified from ygopro2 branch
  • Loading branch information
DailyShana committed Oct 6, 2018
1 parent 25d24f2 commit 8439bab
Show file tree
Hide file tree
Showing 26 changed files with 526 additions and 1 deletion.
42 changes: 42 additions & 0 deletions CMakeLists.txt
@@ -0,0 +1,42 @@
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)
1 change: 1 addition & 0 deletions cmake/compiler/clang-compile.cmake
@@ -0,0 +1 @@
include (compiler/gcc)
4 changes: 4 additions & 0 deletions cmake/compiler/gcc.cmake
@@ -0,0 +1,4 @@
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" )
1 change: 1 addition & 0 deletions cmake/compiler/icc.cmake
@@ -0,0 +1 @@

1 change: 1 addition & 0 deletions cmake/compiler/mingw.cmake
@@ -0,0 +1 @@
add_definitions ( "-static-libgcc" "-static-libstdc++" )
5 changes: 5 additions & 0 deletions cmake/compiler/msvc.cmake
@@ -0,0 +1,5 @@
add_definitions ( "-wd4996" "-D_CRT_SECURE_NO_WARNINGS" "-D_ITERATOR_DEBUG_LEVEL=0" )
add_definitions ( "-D_UNICODE" "-DUNICODE" "/utf-8" )

include (MSVCMultipleProcessCompile)
include (MSVCStaticRuntime)
32 changes: 32 additions & 0 deletions cmake/macros/AutoFiles.cmake
@@ -0,0 +1,32 @@
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 ()
27 changes: 27 additions & 0 deletions cmake/macros/FindDL.cmake
@@ -0,0 +1,27 @@
# - 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)
38 changes: 38 additions & 0 deletions cmake/macros/FindFreetype.cmake
@@ -0,0 +1,38 @@
# - 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)
42 changes: 42 additions & 0 deletions cmake/macros/FindIrrlicht.cmake
@@ -0,0 +1,42 @@
# - 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)
54 changes: 54 additions & 0 deletions cmake/macros/FindLibEvent.cmake
@@ -0,0 +1,54 @@
# - 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)
38 changes: 38 additions & 0 deletions cmake/macros/FindSqlite.cmake
@@ -0,0 +1,38 @@
# - 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)
53 changes: 53 additions & 0 deletions cmake/macros/ListCombinations.cmake
@@ -0,0 +1,53 @@
# - 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()
31 changes: 31 additions & 0 deletions cmake/macros/MSVCMultipleProcessCompile.cmake
@@ -0,0 +1,31 @@
# - 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()

0 comments on commit 8439bab

Please sign in to comment.