├── 1 - Presentation └── 광운대 컴퓨터정보공학부 특강 - ECS 기반 게임 개발.pdf ├── .gitignore ├── 2 - Example ├── Sources │ ├── main.cpp │ ├── Systems │ │ ├── Game.cpp │ │ └── UpgradeSystem.cpp │ ├── Helpers │ │ ├── GoldHelpers.cpp │ │ └── TowerHelpers.cpp │ └── CMakeLists.txt ├── Includes │ ├── Components │ │ ├── Gold.hpp │ │ ├── Name.hpp │ │ └── Upgradable.hpp │ ├── Commons │ │ ├── Tags.hpp │ │ └── Constants.hpp │ ├── Systems │ │ ├── Game.hpp │ │ └── UpgradeSystem.hpp │ └── Helpers │ │ ├── TowerHelpers.hpp │ │ └── GoldHelpers.hpp ├── CMakeLists.txt └── CMake │ └── CompileOptions.cmake ├── LICENSE └── README.md /1 - Presentation/광운대 컴퓨터정보공학부 특강 - ECS 기반 게임 개발.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/utilForever/2022-KW-ECS-Development/HEAD/1 - Presentation/광운대 컴퓨터정보공학부 특강 - ECS 기반 게임 개발.pdf -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | CMakeLists.txt.user 2 | CMakeCache.txt 3 | CMakeFiles 4 | CMakeScripts 5 | Testing 6 | Makefile 7 | cmake_install.cmake 8 | install_manifest.txt 9 | compile_commands.json 10 | CTestTestfile.cmake 11 | _deps 12 | -------------------------------------------------------------------------------- /2 - Example/Sources/main.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 Chris Ohk 2 | // I'm making my contributions/submissions to this project solely in my 3 | // personal capacity and are not conveying any rights to any intellectual 4 | // property of any third parties. 5 | 6 | int main() 7 | { 8 | return 0; 9 | } -------------------------------------------------------------------------------- /2 - Example/Includes/Components/Gold.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 Chris Ohk 2 | // I'm making my contributions/submissions to this project solely in my 3 | // personal capacity and are not conveying any rights to any intellectual 4 | // property of any third parties. 5 | 6 | #ifndef ECS_TOWER_GOLD_HPP 7 | #define ECS_TOWER_GOLD_HPP 8 | 9 | namespace ECSTower 10 | { 11 | //! 12 | //! \brief Gold struct. 13 | //! 14 | //! This struct stores the gold of the entity. 15 | //! 16 | struct Gold 17 | { 18 | int amount; 19 | }; 20 | } // namespace ECSTower 21 | 22 | #endif // ECS_TOWER_GOLD_HPP -------------------------------------------------------------------------------- /2 - Example/Includes/Components/Name.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 Chris Ohk 2 | // I'm making my contributions/submissions to this project solely in my 3 | // personal capacity and are not conveying any rights to any intellectual 4 | // property of any third parties. 5 | 6 | #ifndef ECS_TOWER_NAME_HPP 7 | #define ECS_TOWER_NAME_HPP 8 | 9 | #include 10 | 11 | namespace ECSTower 12 | { 13 | //! 14 | //! \brief Name struct. 15 | //! 16 | //! This struct stores the name of the entity. 17 | //! 18 | struct Name 19 | { 20 | std::string name; 21 | }; 22 | } // namespace ECSTower 23 | 24 | #endif // ECS_TOWER_NAME_HPP -------------------------------------------------------------------------------- /2 - Example/Includes/Commons/Tags.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 Chris Ohk 2 | // I'm making my contributions/submissions to this project solely in my 3 | // personal capacity and are not conveying any rights to any intellectual 4 | // property of any third parties. 5 | 6 | #ifndef ECS_TOWER_TAGS_HPP 7 | #define ECS_TOWER_TAGS_HPP 8 | 9 | #include 10 | 11 | namespace ECSTower 12 | { 13 | namespace Tag 14 | { 15 | using namespace entt::literals; 16 | 17 | using Player = entt::tag<"player"_hs>; 18 | using Tower = entt::tag<"tower"_hs>; 19 | } // namespace Tag 20 | } // namespace ECSTower 21 | 22 | #endif // ECS_TOWER_TAGS_HPP -------------------------------------------------------------------------------- /2 - Example/Includes/Commons/Constants.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 Chris Ohk 2 | // I'm making my contributions/submissions to this project solely in my 3 | // personal capacity and are not conveying any rights to any intellectual 4 | // property of any third parties. 5 | 6 | #ifndef ECS_TOWER_CONSTANTS_HPP 7 | #define ECS_TOWER_CONSTANTS_HPP 8 | 9 | namespace ECSTower 10 | { 11 | //! The price of arrow tower at level 1. 12 | constexpr static int ARROW_TOWER_LV1_PRICE = 100; 13 | 14 | //! The price of arrow tower at level 2. 15 | constexpr static int ARROW_TOWER_LV2_PRICE = 200; 16 | } // namespace ECSTower 17 | 18 | #endif // ECS_TOWER_CONSTANTS_HPP -------------------------------------------------------------------------------- /2 - Example/Includes/Systems/Game.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 Chris Ohk 2 | // I'm making my contributions/submissions to this project solely in my 3 | // personal capacity and are not conveying any rights to any intellectual 4 | // property of any third parties. 5 | 6 | #ifndef ECS_TOWER_GAME_HPP 7 | #define ECS_TOWER_GAME_HPP 8 | 9 | #include 10 | 11 | namespace ECSTower 12 | { 13 | namespace Game 14 | { 15 | //! Initializes entities that are needed to the game. 16 | //! \param registry A registry that handles entities. 17 | void Initialize(entt::registry& registry); 18 | } 19 | } // namespace ECSTower 20 | 21 | #endif // ECS_TOWER_GAME_HPP -------------------------------------------------------------------------------- /2 - Example/Includes/Systems/UpgradeSystem.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 Chris Ohk 2 | // I'm making my contributions/submissions to this project solely in my 3 | // personal capacity and are not conveying any rights to any intellectual 4 | // property of any third parties. 5 | 6 | #ifndef ECS_TOWER_UPGRADE_SYSTEM_HPP 7 | #define ECS_TOWER_UPGRADE_SYSTEM_HPP 8 | 9 | #include 10 | 11 | namespace ECSTower 12 | { 13 | //! Updates upgrade system. 14 | //! \param registry A registry that handles entities. 15 | //! \param from The tower entity to upgrade. 16 | void UpdateUpgradeSystem(entt::registry& registry, entt::entity from); 17 | } // namespace ECSTower 18 | 19 | #endif // ECS_TOWER_UPGRADE_SYSTEM_HPP -------------------------------------------------------------------------------- /2 - Example/Sources/Systems/Game.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 Chris Ohk 2 | // I'm making my contributions/submissions to this project solely in my 3 | // personal capacity and are not conveying any rights to any intellectual 4 | // property of any third parties. 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | namespace ECSTower 11 | { 12 | namespace Game 13 | { 14 | void Initialize(entt::registry& registry) 15 | { 16 | // Player 17 | { 18 | auto entity = registry.create(); 19 | registry.emplace(entity); 20 | registry.emplace(entity, 500); 21 | } 22 | } 23 | } // namespace Game 24 | } // namespace ECSTower -------------------------------------------------------------------------------- /2 - Example/Sources/Helpers/GoldHelpers.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 Chris Ohk 2 | // I'm making my contributions/submissions to this project solely in my 3 | // personal capacity and are not conveying any rights to any intellectual 4 | // property of any third parties. 5 | 6 | #include 7 | #include 8 | 9 | namespace ECSTower 10 | { 11 | bool Withdraw(entt::registry& registry, entt::entity from, int amount) 12 | { 13 | if (!registry.all_of(from)) 14 | { 15 | return false; 16 | } 17 | 18 | if (auto& gold = registry.get(from); gold.amount >= amount) 19 | { 20 | gold.amount -= amount; 21 | return true; 22 | } 23 | 24 | return false; 25 | } 26 | } // namespace ECSTower -------------------------------------------------------------------------------- /2 - Example/Includes/Components/Upgradable.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 Chris Ohk 2 | // I'm making my contributions/submissions to this project solely in my 3 | // personal capacity and are not conveying any rights to any intellectual 4 | // property of any third parties. 5 | 6 | #ifndef ECS_TOWER_UPGRADABLE_HPP 7 | #define ECS_TOWER_UPGRADABLE_HPP 8 | 9 | #include 10 | 11 | #include 12 | 13 | namespace ECSTower 14 | { 15 | //! 16 | //! \brief Upgradable struct. 17 | //! 18 | //! This struct stores the cost and the function to upgrade something. 19 | //! 20 | struct Upgradable 21 | { 22 | int cost; 23 | std::function Upgrade; 24 | }; 25 | } // namespace ECSTower 26 | 27 | #endif // ECS_TOWER_UPGRADABLE_HPP -------------------------------------------------------------------------------- /2 - Example/Includes/Helpers/TowerHelpers.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 Chris Ohk 2 | // I'm making my contributions/submissions to this project solely in my 3 | // personal capacity and are not conveying any rights to any intellectual 4 | // property of any third parties. 5 | 6 | #ifndef ECS_TOWER_TOWER_HELPERS_HPP 7 | #define ECS_TOWER_TOWER_HELPERS_HPP 8 | 9 | #include 10 | 11 | namespace ECSTower 12 | { 13 | //! Buys a arrow tower. 14 | //! \param registry A registry that handles entities. 15 | void BuyArrowTower(entt::registry& registry); 16 | 17 | //! Upgrades a arrow tower to level 2. 18 | //! \param registry A registry that handles entities. 19 | //! \param entity A arrow tower entity to upgrade. 20 | void UpgradeArrowTowerLv2(entt::registry& registry, entt::entity entity); 21 | } // namespace ECSTower 22 | 23 | #endif // ECS_TOWER_TOWER_HELPERS_HPP -------------------------------------------------------------------------------- /2 - Example/Includes/Helpers/GoldHelpers.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 Chris Ohk 2 | // I'm making my contributions/submissions to this project solely in my 3 | // personal capacity and are not conveying any rights to any intellectual 4 | // property of any third parties. 5 | 6 | #ifndef ECS_TOWER_GOLD_HELPERS_HPP 7 | #define ECS_TOWER_GOLD_HELPERS_HPP 8 | 9 | #include 10 | 11 | namespace ECSTower 12 | { 13 | //! Withdraws \p amount from \p from's Gold component if enough gold in it, then 14 | //! return true. Returns false otherwise and leave \p from's Gold untouched. 15 | //! \param registry A registry that handles entities. 16 | //! \param from The player entity. 17 | //! \param amount The price to buy something. 18 | bool Withdraw(entt::registry& registry, entt::entity from, int amount); 19 | } // namespace ECSTower 20 | 21 | #endif // ECS_TOWER_GOLD_HELPERS_HPP -------------------------------------------------------------------------------- /2 - Example/Sources/Systems/UpgradeSystem.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 Chris Ohk 2 | // I'm making my contributions/submissions to this project solely in my 3 | // personal capacity and are not conveying any rights to any intellectual 4 | // property of any third parties. 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | namespace ECSTower 12 | { 13 | void UpdateUpgradeSystem(entt::registry& registry, entt::entity from) 14 | { 15 | if (registry.all_of(from)) 16 | { 17 | if (const auto& upgradable = registry.get(from); Withdraw( 18 | registry, registry.view()[0], upgradable.cost)) 19 | { 20 | upgradable.Upgrade(registry, from); 21 | } 22 | } 23 | } 24 | } // namespace ECSTower -------------------------------------------------------------------------------- /2 - Example/Sources/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Target name 2 | set(target ECSTower) 3 | 4 | # Define 5 | set(root_dir ${CMAKE_CURRENT_SOURCE_DIR}/..) 6 | 7 | # Includes 8 | include_directories( 9 | ${CMAKE_CURRENT_SOURCE_DIR} 10 | ) 11 | 12 | # Sources 13 | file(GLOB header_dir 14 | ${root_dir}/Includes) 15 | 16 | file(GLOB_RECURSE headers 17 | ${header_dir}/*.hpp) 18 | 19 | file(GLOB_RECURSE sources 20 | ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp) 21 | 22 | # Build library 23 | add_executable(${target} 24 | ${sources}) 25 | 26 | # Project options 27 | set_target_properties(${target} 28 | PROPERTIES 29 | ${DEFAULT_PROJECT_OPTIONS} 30 | ) 31 | 32 | # Compile options 33 | target_compile_options(${target} 34 | PRIVATE 35 | 36 | PUBLIC 37 | ${DEFAULT_COMPILE_OPTIONS} 38 | 39 | INTERFACE 40 | ) 41 | 42 | target_link_libraries(${target} 43 | PRIVATE 44 | 45 | PUBLIC 46 | ${DEFAULT_LINKER_OPTIONS} 47 | ${DEFAULT_LIBRARIES} 48 | 49 | INTERFACE 50 | ) -------------------------------------------------------------------------------- /2 - Example/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # CMake version 2 | cmake_minimum_required(VERSION 3.8.2 FATAL_ERROR) 3 | 4 | # Include cmake modules 5 | list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMake") 6 | 7 | # Declare project 8 | project(ECSTower) 9 | 10 | # Set output directories 11 | set(DEFAULT_CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}) 12 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin) 13 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib) 14 | set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib) 15 | 16 | # Set enable output of compile commands during generation 17 | set(CMAKE_EXPORT_COMPILE_COMMANDS ON) 18 | 19 | # Includes 20 | include_directories(Includes) 21 | include_directories(Libraries) 22 | 23 | # Compile options 24 | include(CMake/CompileOptions.cmake) 25 | 26 | # Build type - Release by default 27 | if(NOT CMAKE_BUILD_TYPE) 28 | set(CMAKE_BUILD_TYPE Release) 29 | endif() 30 | 31 | # Overrides 32 | set(CMAKE_MACOSX_RPATH ON) 33 | 34 | # Project modules 35 | add_subdirectory(Sources) -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 Chris Ohk 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /2 - Example/Sources/Helpers/TowerHelpers.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 Chris Ohk 2 | // I'm making my contributions/submissions to this project solely in my 3 | // personal capacity and are not conveying any rights to any intellectual 4 | // property of any third parties. 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | namespace ECSTower 14 | { 15 | void BuyArrowTower(entt::registry& registry) 16 | { 17 | // Check the player can buy arrow tower 18 | if (!Withdraw(registry, registry.view()[0], 19 | ARROW_TOWER_LV1_PRICE)) 20 | { 21 | return; 22 | } 23 | 24 | auto entity = registry.create(); 25 | registry.emplace(entity); 26 | registry.emplace(entity, "Arrow Tower Lv 1"); 27 | registry.emplace(entity, ARROW_TOWER_LV2_PRICE, 28 | UpgradeArrowTowerLv2); 29 | } 30 | 31 | void UpgradeArrowTowerLv2(entt::registry& registry, entt::entity entity) 32 | { 33 | registry.replace(entity, "Arrow Tower Lv 2"); 34 | registry.remove(entity); 35 | } 36 | } // namespace ECSTower -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # 2022-KW-ECS-Development 2 | 3 | 2022년 광운대학교 컴퓨터정보공학부 특강 - ECS 기반 게임 개발 발표 자료 및 예제 코드 4 | 5 | ## Contents 6 | 7 | - [Presentation](./1%20-%20Presentation/광운대%20컴퓨터정보공학부%20특강%20-%20ECS%20기반%20게임%20개발.pdf) 8 | 9 | - [Example](./2%20-%20Example) 10 | 11 | ## Quick Start 12 | 13 | For macOS or Linux or Windows Subsystem for Linux (WSL): 14 | 15 | ``` 16 | mkdir build 17 | cd build 18 | cmake .. 19 | make 20 | ``` 21 | 22 | For Windows: 23 | 24 | ``` 25 | mkdir build 26 | cd build 27 | cmake .. -G"Visual Studio 15 2017 Win64" 28 | MSBuild ECSTower.sln /p:Configuration=Release 29 | ``` 30 | 31 | ## Acknowledgement 32 | 33 | The example code `ECSTower` uses ECS library [entt](https://github.com/skypjack/entt) made by [Michele Caini](https://twitter.com/scaipgec). Thanks! 34 | 35 | ## How To Contribute 36 | 37 | Contributions are always welcome, either reporting issues/bugs or forking the repository and then issuing pull requests when you have completed some additional coding that you feel will be beneficial to the main project. If you are interested in contributing in a more dedicated capacity, then please contact me. 38 | 39 | ## Contact 40 | 41 | You can contact me via e-mail (utilForever at gmail.com). I am always happy to answer questions or help with any issues you might have, and please be sure to share any additional work or your creations with me, I love seeing what other people are making. 42 | 43 | ## License 44 | 45 | 46 | 47 | The class is licensed under the [MIT License](http://opensource.org/licenses/MIT): 48 | 49 | Copyright © 2022 [Chris Ohk](http://www.github.com/utilForever). 50 | 51 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 52 | 53 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 54 | 55 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /2 - Example/CMake/CompileOptions.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Platform and architecture setup 3 | # 4 | 5 | # Set warnings as errors flag 6 | option(ECS_TOWER_WARNINGS_AS_ERRORS "Treat all warnings as errors" ON) 7 | if(ECS_TOWER_WARNINGS_AS_ERRORS) 8 | if(CMAKE_CXX_COMPILER_ID MATCHES "MSVC") 9 | set(WARN_AS_ERROR_FLAGS "/WX") 10 | else() 11 | set(WARN_AS_ERROR_FLAGS "-Werror") 12 | endif() 13 | endif() 14 | 15 | # Get upper case system name 16 | string(TOUPPER ${CMAKE_SYSTEM_NAME} SYSTEM_NAME_UPPER) 17 | 18 | # Determine architecture (32/64 bit) 19 | set(X64 OFF) 20 | if(CMAKE_SIZEOF_VOID_P EQUAL 8) 21 | set(X64 ON) 22 | endif() 23 | 24 | # 25 | # Project options 26 | # 27 | 28 | set(DEFAULT_PROJECT_OPTIONS 29 | CXX_STANDARD 17 # Not available before CMake 3.8.2; see below for manual command line argument addition 30 | LINKER_LANGUAGE "CXX" 31 | POSITION_INDEPENDENT_CODE ON 32 | ) 33 | 34 | # 35 | # Include directories 36 | # 37 | 38 | set(DEFAULT_INCLUDE_DIRECTORIES) 39 | 40 | # 41 | # Libraries 42 | # 43 | 44 | set(DEFAULT_LIBRARIES) 45 | 46 | # 47 | # Compile definitions 48 | # 49 | 50 | set(DEFAULT_COMPILE_DEFINITIONS 51 | SYSTEM_${SYSTEM_NAME_UPPER} 52 | ) 53 | 54 | # MSVC compiler options 55 | if (CMAKE_CXX_COMPILER_ID MATCHES "MSVC") 56 | set(DEFAULT_COMPILE_DEFINITIONS ${DEFAULT_COMPILE_DEFINITIONS} 57 | _SCL_SECURE_NO_WARNINGS # Calling any one of the potentially unsafe methods in the Standard C++ Library 58 | _CRT_SECURE_NO_WARNINGS # Calling any one of the potentially unsafe methods in the CRT Library 59 | ) 60 | endif () 61 | 62 | # 63 | # Compile options 64 | # 65 | 66 | set(DEFAULT_COMPILE_OPTIONS) 67 | 68 | # MSVC compiler options 69 | if (CMAKE_CXX_COMPILER_ID MATCHES "MSVC") 70 | # remove default warning level from CMAKE_CXX_FLAGS 71 | string (REGEX REPLACE "/W[0-4]" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") 72 | endif() 73 | 74 | # MSVC compiler options 75 | if (CMAKE_CXX_COMPILER_ID MATCHES "MSVC") 76 | set(DEFAULT_COMPILE_OPTIONS ${DEFAULT_COMPILE_OPTIONS} 77 | /MP # -> build with multiple processes 78 | /W4 # -> warning level 4 79 | ${WARN_AS_ERROR_FLAGS} 80 | 81 | /wd4819 # -> disable warning: The file contains a character that cannot be represented in the current code page (949) (caused by entt) 82 | /wd4307 # -> disable warning: warning C4307: '*': integral constant overflow (caused by entt) 83 | /wd4100 # -> disable warning: warning C4100: 'op': unreferenced formal parameter (caused by entt) 84 | 85 | #$<$: 86 | #/RTCc # -> value is assigned to a smaller data type and results in a data loss 87 | #> 88 | 89 | $<$: 90 | /Gw # -> whole program global optimization 91 | /GS- # -> buffer security check: no 92 | /GL # -> whole program optimization: enable link-time code generation (disables Zi) 93 | /GF # -> enable string pooling 94 | > 95 | ) 96 | endif () 97 | 98 | # GCC and Clang compiler options 99 | if (CMAKE_CXX_COMPILER_ID MATCHES "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") 100 | set(DEFAULT_COMPILE_OPTIONS ${DEFAULT_COMPILE_OPTIONS} 101 | -Wall 102 | -Wno-missing-braces 103 | -Wno-register # -> disable warning: ISO c++1z does not allow 'register' storage class specifier [-wregister] (caused by pybind11) 104 | -Wno-error=register # -> disable warning: ISO c++1z does not allow 'register' storage class specifier [-wregister] (caused by pybind11) 105 | 106 | ${WARN_AS_ERROR_FLAGS} 107 | -std=c++1z 108 | ) 109 | endif () 110 | 111 | if (CMAKE_CXX_COMPILER_ID MATCHES "GNU") 112 | set(DEFAULT_COMPILE_OPTIONS ${DEFAULT_COMPILE_OPTIONS} 113 | -Wno-int-in-bool-context 114 | ) 115 | endif () 116 | 117 | # 118 | # Linker options 119 | # 120 | 121 | set(DEFAULT_LINKER_OPTIONS) 122 | 123 | # Use pthreads on mingw and linux 124 | if (CMAKE_CXX_COMPILER_ID MATCHES "GNU" OR CMAKE_SYSTEM_NAME MATCHES "Linux") 125 | set(DEFAULT_LINKER_OPTIONS 126 | -pthread 127 | -lstdc++fs 128 | ) 129 | endif() --------------------------------------------------------------------------------