Setup and clear of string pool.
[SquirrelJME.git] / nanocoat / CMakeLists.txt
blob762b2d836ccc9650da70eb7eec4b962a8c6675d3
1 # ---------------------------------------------------------------------------
2 # SquirrelJME
3 #     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
4 # ---------------------------------------------------------------------------
5 # SquirrelJME is under the Mozilla Public License Version 2.0.
6 # See license.mkd for licensing and copyright information.
7 # ---------------------------------------------------------------------------
8 # DESCRIPTION: Defines the base project and the versioning info
10 # Easier includes
11 include("${CMAKE_SOURCE_DIR}/cmake/easier-includes.cmake" NO_POLICY_SCOPE)
13 # Needed for some ancient RetroArch toolchains
14 if(${CMAKE_VERSION} VERSION_LESS "3.13")
15         message(STATUS "Ancient CMake has been detected (${CMAKE_VERSION})")
16         cmake_minimum_required(VERSION 3.7)
18         # Needs to be this or newer
19 else()
20         message(STATUS "Detected CMake (${CMAKE_VERSION})")
21         cmake_minimum_required(VERSION 3.13)
22 endif()
24 # Determine version information
25 squirreljme_include("identify-squirreljme-version.cmake")
27 # Soft patching of CMake for older version support
28 squirreljme_include("cmake-patch.cmake")
30 # Fixes and otherwise for compatibility
31 squirreljme_include("pre-fixes.cmake")
33 # Define project
34 if(${CMAKE_VERSION} VERSION_LESS "3.12")
35         project(SquirrelJME
36                 VERSION ${SQUIRRELJME_VERSION}
37                 LANGUAGES C)
38 else()
39         project(SquirrelJME
40                 VERSION ${SQUIRRELJME_VERSION}
41                 DESCRIPTION "SquirrelJME is a Java ME 8 \
42 Virtual Machine for embedded and Internet of Things devices."
43                 HOMEPAGE_URL https://squirreljme.cc/
44                 LANGUAGES C)
45 endif()
47 # CMake Utilities, compiled and used during build
48 squirreljme_include("utils.cmake")
50 # Platform information
51 squirreljme_include("platform.cmake")
53 # Fixes and otherwise for compatibility
54 squirreljme_include("fixes.cmake")
56 # Use for all builds
57 add_compile_definitions(SJME_CONFIG_BUILD_ARCH=${SQUIRRELJME_ARCH})
58 add_compile_definitions(SJME_CONFIG_BUILD_PLATFORM=${SQUIRRELJME_PLATFORM})
60 # Win32 Options
61 squirreljme_include("win32.cmake")
63 # Hardening options
64 squirreljme_include("hardening.cmake")
66 # Is the system JNI available?
67 squirreljme_include("jni.cmake")
69 # Doxygen
70 squirreljme_include("doxygen.cmake")
72 # Threading and atomics
73 squirreljme_include("threads.cmake")
75 # To Emily and Near...
76 squirreljme_include("i-miss-you.cmake")
78 # Everything is C99
79 set(CMAKE_C_STANDARD 99)
80 set(CMAKE_C_STANDARD_REQUIRED True)
82 # Optimization for size, since embedded, if not debugging
83 if(SQUIRRELJME_IS_RELEASE)
84         if(CMAKE_COMPILER_IS_GNUCC OR
85                 CMAKE_COMPILER_IS_GNUCXX OR
86                 CMAKE_C_COMPILER_ID STREQUAL "GNU" OR
87                 CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
88                 add_compile_options("-Os")
89         elseif(MSVC OR
90                 CMAKE_C_COMPILER_ID STREQUAL "MSVC" OR
91                 CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
92                 add_compile_options("/Os")
93         endif()
94 endif()
96 # Assets and otherwise, such as icons, etc.
97 squirreljme_include("assets.cmake")
99 # Multi-library declarations
100 squirreljme_include("multilib.cmake")
102 # Distribution
103 squirreljme_include("distrib.cmake")
105 # Visual studio does not like a bunch of standard C functions, even those
106 # that take sizes...
107 if(MSVC)
108         add_compile_definitions(_CRT_SECURE_NO_WARNINGS=1)
109 endif()
111 # Declare Version
112 add_compile_definitions(
113         SQUIRRELJME_VERSION_TRIM=${SQUIRRELJME_VERSION})
115 # Debugging?
116 if(SQUIRRELJME_IS_DEBUG)
117         add_compile_definitions(SJME_CONFIG_DEBUG=1)
119         if(SQUIRRELJME_ENABLE_TESTING)
120                 add_compile_definitions(SJME_CONFIG_UNIT_TEST=1)
121         endif()
122 endif()
124 # Valgrind Support on UNIX OSes, if debugging is enabled
125 if(ANDROID OR SQUIRRELJME_IS_UNIX)
126         if(SQUIRRELJME_IS_DEBUG)
127                 squirreljme_include("valgrind.cmake")
128         endif()
129 endif()
131 # Where should dynamic libraries go when output?
132 if(NOT DEFINED SQUIRRELJME_DYLIB_OUTPUT_DIR)
133         set(SQUIRRELJME_DYLIB_OUTPUT_DIR
134                 "${CMAKE_BINARY_DIR}")
135 endif()
137 # Enable support for testing, this is needed here otherwise testing will not
138 # work at all! Major headache this has caused...
139 # From: https://cmake.org/cmake/help/v3.13/command/enable_testing.html
140 # > Note that ctest expects to find a test file in the build directory root.
141 # > Therefore, this command should be in the source directory root.
142 if(SQUIRRELJME_ENABLE_TESTING)
143         enable_testing()
144 else()
145         message(WARNING "Testing was disabled "
146                 "(${SQUIRRELJME_ENABLE_TESTING})...")
147 endif()
149 # CPack for installing
150 if(SQUIRRELJME_ENABLE_PACKING OR
151         NOT DEFINED SQUIRRELJME_ENABLE_PACKING)
152         squirreljme_include("packing.cmake")
153 endif()
155 # SquirrelJME Base Library, everything depends on this essentially
156 add_subdirectory(lib/base)
158 # Include the base core first because it is completely standalone and it
159 # uses nothing else
160 add_subdirectory(src)
162 # Internal Libraries other than Base
163 add_subdirectory(lib)
165 # Tests first since we add to these and when the ROMs register themselves
166 # they will get their tests added accordingly
167 if(SQUIRRELJME_ENABLE_TESTING)
168         add_subdirectory(tests)
169 else()
170         message(WARNING "Testing was disabled "
171                 "(${SQUIRRELJME_ENABLE_TESTING})...")
172 endif()
174 # Front ends
175 add_subdirectory(frontend)
177 # Directory where the ROM compiled sources exist
178 add_subdirectory(rom)