mirror of
https://github.com/enduro2d/enduro2d.git
synced 2026-01-05 01:51:02 +07:00
134
CMakeLists.txt
134
CMakeLists.txt
@@ -6,38 +6,24 @@ project(enduro2d)
|
||||
#
|
||||
|
||||
if(NOT CMAKE_BUILD_TYPE)
|
||||
set(CMAKE_BUILD_TYPE Release)
|
||||
set(CMAKE_BUILD_TYPE Release)
|
||||
endif(NOT CMAKE_BUILD_TYPE)
|
||||
|
||||
foreach(flags CMAKE_C_FLAGS_DEBUG
|
||||
CMAKE_CXX_FLAGS_DEBUG)
|
||||
set(${flags} "${${flags}} -D_DEBUG -DNRELEASE")
|
||||
endforeach(flags)
|
||||
|
||||
foreach(flags CMAKE_C_FLAGS_RELEASE
|
||||
CMAKE_C_FLAGS_MINSIZEREL
|
||||
CMAKE_C_FLAGS_RELWITHDEBINFO
|
||||
CMAKE_CXX_FLAGS_RELEASE
|
||||
CMAKE_CXX_FLAGS_MINSIZEREL
|
||||
CMAKE_CXX_FLAGS_RELWITHDEBINFO)
|
||||
set(${flags} "${${flags}} -DNDEBUG -D_RELEASE")
|
||||
endforeach(flags)
|
||||
|
||||
#
|
||||
# warning mode
|
||||
#
|
||||
|
||||
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
||||
add_compile_options(-Wall -Wextra -Wpedantic)
|
||||
add_compile_options(-Wall -Wextra -Wpedantic)
|
||||
elseif(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
|
||||
add_compile_options(-Wall -Wextra -Wpedantic)
|
||||
add_compile_options(-Wall -Wextra -Wpedantic)
|
||||
elseif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
|
||||
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
|
||||
if(CMAKE_CXX_FLAGS MATCHES "/W[0-4]")
|
||||
string(REGEX REPLACE "/W[0-4]" "/W4" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
||||
else()
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4")
|
||||
endif()
|
||||
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
|
||||
if(CMAKE_CXX_FLAGS MATCHES "/W[0-4]")
|
||||
string(REGEX REPLACE "/W[0-4]" "/W4" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
||||
else()
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
#
|
||||
@@ -45,70 +31,102 @@ endif()
|
||||
#
|
||||
|
||||
file(GLOB_RECURSE E2D_HEADERS
|
||||
headers/enduro2d/*.hpp
|
||||
headers/enduro2d/*.inl)
|
||||
headers/enduro2d/*.hpp
|
||||
headers/enduro2d/*.inl)
|
||||
|
||||
file(GLOB_RECURSE E2D_SOURCES
|
||||
sources/enduro2d/*.cpp
|
||||
sources/enduro2d/*.hpp
|
||||
headers/enduro2d/*.inl)
|
||||
sources/enduro2d/*.cpp
|
||||
sources/enduro2d/*.hpp
|
||||
headers/enduro2d/*.inl)
|
||||
|
||||
if(APPLE)
|
||||
file(GLOB_RECURSE E2D_SOURCES_MM
|
||||
sources/enduro2d/*.mm)
|
||||
list(APPEND E2D_SOURCES ${E2D_SOURCES_MM})
|
||||
file(GLOB_RECURSE E2D_SOURCES_MM
|
||||
sources/enduro2d/*.mm)
|
||||
list(APPEND E2D_SOURCES
|
||||
${E2D_SOURCES_MM})
|
||||
endif()
|
||||
|
||||
#
|
||||
# e2d 3rd party
|
||||
# e2d internal 3rd party
|
||||
#
|
||||
|
||||
file(GLOB_RECURSE E2D_3RDPARTY
|
||||
sources/3rdparty/*.*)
|
||||
sources/3rdparty/*.*)
|
||||
|
||||
#
|
||||
# e2d library target
|
||||
# e2d external 3rd party
|
||||
#
|
||||
|
||||
add_library(${PROJECT_NAME} STATIC
|
||||
${E2D_HEADERS}
|
||||
${E2D_SOURCES}
|
||||
${E2D_3RDPARTY})
|
||||
find_package(OpenGL REQUIRED)
|
||||
find_package(Threads REQUIRED)
|
||||
|
||||
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES
|
||||
${E2D_HEADERS}
|
||||
${E2D_SOURCES}
|
||||
${E2D_3RDPARTY})
|
||||
|
||||
target_include_directories(${PROJECT_NAME} PRIVATE
|
||||
headers
|
||||
sources)
|
||||
|
||||
set_target_properties(${PROJECT_NAME} PROPERTIES
|
||||
CXX_STANDARD 14
|
||||
CXX_STANDARD_REQUIRED YES
|
||||
CXX_EXTENSIONS NO)
|
||||
|
||||
#
|
||||
# glfw module
|
||||
#
|
||||
if(APPLE)
|
||||
find_library(Cocoa Cocoa)
|
||||
find_library(IOKit IOKit)
|
||||
find_library(CoreVideo CoreVideo)
|
||||
find_library(Foundation Foundation)
|
||||
endif(APPLE)
|
||||
|
||||
set(GLFW_BUILD_DOCS OFF CACHE BOOL "" FORCE)
|
||||
set(GLFW_BUILD_TESTS OFF CACHE BOOL "" FORCE)
|
||||
set(GLFW_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)
|
||||
add_subdirectory(modules/glfw)
|
||||
|
||||
#
|
||||
# e2d library target
|
||||
#
|
||||
|
||||
add_library(${PROJECT_NAME} STATIC
|
||||
${E2D_HEADERS}
|
||||
${E2D_SOURCES}
|
||||
${E2D_3RDPARTY})
|
||||
|
||||
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES
|
||||
${E2D_HEADERS}
|
||||
${E2D_SOURCES}
|
||||
${E2D_3RDPARTY})
|
||||
|
||||
target_include_directories(${PROJECT_NAME} PRIVATE
|
||||
headers
|
||||
sources)
|
||||
|
||||
set_target_properties(${PROJECT_NAME} PROPERTIES
|
||||
CXX_STANDARD 14
|
||||
CXX_STANDARD_REQUIRED YES
|
||||
CXX_EXTENSIONS NO)
|
||||
|
||||
#
|
||||
# e2d public variables
|
||||
#
|
||||
|
||||
set(E2D_INCLUDE_DIRS
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/headers)
|
||||
|
||||
set(E2D_LIBRARIES
|
||||
enduro2d
|
||||
glfw
|
||||
${OPENGL_gl_LIBRARY}
|
||||
${CMAKE_THREAD_LIBS_INIT})
|
||||
|
||||
if(APPLE)
|
||||
list(APPEND ${E2D_LIBRARIES}
|
||||
${Cocoa}
|
||||
${IOKit}
|
||||
${CoreVideo}
|
||||
${Foundation})
|
||||
endif(APPLE)
|
||||
|
||||
#
|
||||
# subdirectories
|
||||
#
|
||||
|
||||
option(E2D_BUILD_SAMPLES "Build samples" ON)
|
||||
if(E2D_BUILD_SAMPLES)
|
||||
add_subdirectory(samples)
|
||||
add_subdirectory(samples)
|
||||
endif()
|
||||
|
||||
option(E2D_BUILD_UNTESTS "Build untests" ON)
|
||||
if(E2D_BUILD_UNTESTS)
|
||||
enable_testing()
|
||||
add_subdirectory(untests)
|
||||
enable_testing()
|
||||
add_subdirectory(untests)
|
||||
endif()
|
||||
|
||||
@@ -10,5 +10,6 @@
|
||||
|
||||
#include "configs.hpp"
|
||||
#include "macros.hpp"
|
||||
#include "main.hpp"
|
||||
#include "stdex.hpp"
|
||||
#include "types.hpp"
|
||||
|
||||
@@ -66,10 +66,10 @@
|
||||
#define E2D_BUILD_MODE_RELEASE 2
|
||||
|
||||
#ifndef E2D_BUILD_MODE
|
||||
# if defined(DEBUG) || defined(_DEBUG) || defined(NRELEASE)
|
||||
# define E2D_BUILD_MODE E2D_BUILD_MODE_DEBUG
|
||||
# elif defined(RELEASE) || defined(_RELEASE) || defined(NDEBUG)
|
||||
# if defined(RELEASE) || defined(_RELEASE) || defined(NDEBUG)
|
||||
# define E2D_BUILD_MODE E2D_BUILD_MODE_RELEASE
|
||||
# else
|
||||
# define E2D_BUILD_MODE E2D_BUILD_MODE_DEBUG
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
* Copyright (C) 2018 Matvey Cherevko
|
||||
******************************************************************************/
|
||||
|
||||
#include <enduro2d/base/_all.hpp>
|
||||
#pragma once
|
||||
|
||||
#if defined(E2D_COMPILER) && E2D_COMPILER == E2D_COMPILER_GCC
|
||||
#include "types.hpp"
|
||||
|
||||
#endif
|
||||
e2d::i32 e2d_main();
|
||||
@@ -1,20 +1,6 @@
|
||||
function(add_e2d_sample NAME)
|
||||
set(SAMPLE_NAME sample_${NAME})
|
||||
|
||||
#
|
||||
# external
|
||||
#
|
||||
|
||||
find_package(OpenGL REQUIRED)
|
||||
find_package(Threads REQUIRED)
|
||||
|
||||
if(APPLE)
|
||||
find_library(Cocoa Cocoa)
|
||||
find_library(IOKit IOKit)
|
||||
find_library(CoreVideo CoreVideo)
|
||||
find_library(Foundation Foundation)
|
||||
endif(APPLE)
|
||||
|
||||
#
|
||||
# sources
|
||||
#
|
||||
@@ -31,24 +17,10 @@ function(add_e2d_sample NAME)
|
||||
|
||||
add_executable(${SAMPLE_NAME}
|
||||
${SAMPLE_SOURCES})
|
||||
|
||||
target_include_directories(${SAMPLE_NAME}
|
||||
PRIVATE "../headers")
|
||||
|
||||
target_link_libraries(${SAMPLE_NAME}
|
||||
enduro2d
|
||||
glfw
|
||||
${OPENGL_gl_LIBRARY}
|
||||
${CMAKE_THREAD_LIBS_INIT})
|
||||
|
||||
if(APPLE)
|
||||
target_link_libraries(${SAMPLE_NAME}
|
||||
${Cocoa}
|
||||
${IOKit}
|
||||
${CoreVideo}
|
||||
${Foundation})
|
||||
endif(APPLE)
|
||||
|
||||
${E2D_LIBRARIES})
|
||||
target_include_directories(${SAMPLE_NAME}
|
||||
PRIVATE ${E2D_INCLUDE_DIRS})
|
||||
set_target_properties(${SAMPLE_NAME} PROPERTIES
|
||||
CXX_STANDARD 14
|
||||
CXX_STANDARD_REQUIRED YES
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#include "../common.hpp"
|
||||
using namespace e2d;
|
||||
|
||||
int main() {
|
||||
int e2d_main() {
|
||||
input& i = modules::initialize<input>();
|
||||
debug& d = modules::initialize<debug>();
|
||||
window& w = modules::initialize<window>(
|
||||
@@ -27,4 +27,5 @@ int main() {
|
||||
w.swap_buffers();
|
||||
window::frame_tick();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#include "../common.hpp"
|
||||
using namespace e2d;
|
||||
|
||||
int main() {
|
||||
int e2d_main() {
|
||||
input& i = modules::initialize<input>();
|
||||
debug& d = modules::initialize<debug>();
|
||||
window& w = modules::initialize<window>(
|
||||
@@ -27,4 +27,5 @@ int main() {
|
||||
w.swap_buffers();
|
||||
window::frame_tick();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
#include <enduro2d/base/_all.hpp>
|
||||
|
||||
#if defined(E2D_COMPILER) && E2D_COMPILER == E2D_COMPILER_CLANG
|
||||
|
||||
#endif
|
||||
int main(int argc, char *argv[]) {
|
||||
E2D_UNUSED(argc, argv);
|
||||
return e2d_main();
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* This file is part of the "Enduro2D"
|
||||
* For conditions of distribution and use, see copyright notice in LICENSE.md
|
||||
* Copyright (C) 2018 Matvey Cherevko
|
||||
******************************************************************************/
|
||||
|
||||
#include <enduro2d/base/_all.hpp>
|
||||
|
||||
#if defined(E2D_COMPILER) && E2D_COMPILER == E2D_COMPILER_MSVC
|
||||
|
||||
#endif
|
||||
@@ -1,15 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* This file is part of the "Enduro2D"
|
||||
* For conditions of distribution and use, see copyright notice in LICENSE.md
|
||||
* Copyright (C) 2018 Matvey Cherevko
|
||||
******************************************************************************/
|
||||
|
||||
#include <enduro2d/base/_all.hpp>
|
||||
|
||||
#if defined(E2D_PLATFORM) && E2D_PLATFORM == E2D_PLATFORM_IOS
|
||||
|
||||
int main() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,15 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* This file is part of the "Enduro2D"
|
||||
* For conditions of distribution and use, see copyright notice in LICENSE.md
|
||||
* Copyright (C) 2018 Matvey Cherevko
|
||||
******************************************************************************/
|
||||
|
||||
#include <enduro2d/base/_all.hpp>
|
||||
|
||||
#if defined(E2D_PLATFORM) && E2D_PLATFORM == E2D_PLATFORM_LINUX
|
||||
|
||||
int main() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,15 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* This file is part of the "Enduro2D"
|
||||
* For conditions of distribution and use, see copyright notice in LICENSE.md
|
||||
* Copyright (C) 2018 Matvey Cherevko
|
||||
******************************************************************************/
|
||||
|
||||
#include <enduro2d/base/_all.hpp>
|
||||
|
||||
#if defined(E2D_PLATFORM) && E2D_PLATFORM == E2D_PLATFORM_MACOSX
|
||||
|
||||
int main() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,15 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* This file is part of the "Enduro2D"
|
||||
* For conditions of distribution and use, see copyright notice in LICENSE.md
|
||||
* Copyright (C) 2018 Matvey Cherevko
|
||||
******************************************************************************/
|
||||
|
||||
#include <enduro2d/base/_all.hpp>
|
||||
|
||||
#if defined(E2D_PLATFORM) && E2D_PLATFORM == E2D_PLATFORM_WINDOWS
|
||||
|
||||
int main() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,16 +1,6 @@
|
||||
function(add_e2d_tests NAME)
|
||||
set(TESTS_NAME untests_${NAME})
|
||||
|
||||
#
|
||||
# external
|
||||
#
|
||||
|
||||
find_package(Threads REQUIRED)
|
||||
|
||||
if(APPLE)
|
||||
find_library(Foundation Foundation)
|
||||
endif(APPLE)
|
||||
|
||||
#
|
||||
# sources
|
||||
#
|
||||
@@ -27,19 +17,10 @@ function(add_e2d_tests NAME)
|
||||
|
||||
add_executable(${TESTS_NAME}
|
||||
${TESTS_SOURCES})
|
||||
|
||||
target_include_directories(${TESTS_NAME}
|
||||
PRIVATE "../headers")
|
||||
|
||||
target_link_libraries(${TESTS_NAME}
|
||||
enduro2d
|
||||
"${CMAKE_THREAD_LIBS_INIT}")
|
||||
|
||||
if(APPLE)
|
||||
target_link_libraries(${TESTS_NAME}
|
||||
${Foundation})
|
||||
endif(APPLE)
|
||||
|
||||
${E2D_LIBRARIES})
|
||||
target_include_directories(${TESTS_NAME}
|
||||
PRIVATE ${E2D_INCLUDE_DIRS})
|
||||
set_target_properties(${TESTS_NAME} PROPERTIES
|
||||
CXX_STANDARD 14
|
||||
CXX_STANDARD_REQUIRED YES
|
||||
|
||||
Reference in New Issue
Block a user