summaryrefslogtreecommitdiffstats
path: root/CMakeLists.txt
diff options
context:
space:
mode:
authorAlexey Gavrilov <alexey.gavrilov@mail.com>2026-03-28 14:55:53 +0700
committerAlexey Gavrilov <alexey.gavrilov@mail.com>2026-03-28 14:55:53 +0700
commit378972285342f52bb71822d87ba261b76b4a42ed (patch)
tree20ac43a02dce05e09272865f961f2e3decceda1f /CMakeLists.txt
parentc62baf8bca986d493e1caf441ea7a6b9d1c1823f (diff)
Cmake build type at the generation stage
Fix in *nasm* files - set architecture bitness. Move compiler flags from *toolchain* file to *requirements target* considering cmake files. This solution allows available of multi-configurations generators to pass compiler options without affecting on single-configuration generators. TODO - Debug information - Image creation - Build under window platform (optional) Signed-off-by: Alexey Gavrilov <alexey.gavrilov@mail.com>
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt25
1 files changed, 18 insertions, 7 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index b093d80..c6d9912 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -4,8 +4,13 @@
# Expected input variables:
# ARCH: type of architecture
-set(CXX_FLAGS
- -Wall
+cmake_minimum_required(VERSION 3.25)
+
+project(ObjectiveProject LANGUAGES CXX ASM_NASM)
+
+set(ObjectiveProject_CXX_FLAGS
+ $<$<CONFIG:Debug>:-Wall -Wextra -ggdb -g3 -O0>
+ $<$<CONFIG:Release>:-Wall -Werror>
-ffreestanding
-nostdinc
-nostdlib
@@ -13,9 +18,10 @@ set(CXX_FLAGS
-mgeneral-regs-only
)
-cmake_minimum_required(VERSION 3.25)
-
-project(ObjectiveProject LANGUAGES CXX ASM_NASM)
+set(ObjectiveProject_ASM_NASM_FLAGS
+ $<$<CONFIG:Debug>:-g -O0 -Wall>
+ $<$<CONFIG:RELEASE>:-Wall>
+)
list(APPEND CMAKE_MODULE_PATH
"${ObjectiveProject_SOURCE_DIR}/cmake/module"
@@ -36,11 +42,12 @@ endif()
# Create target with compiler requirements (include directories, flags and etc)
add_library(CXX_COMPILER_REQUIREMENTS INTERFACE)
+add_library(ASM_NASM_COMPILER_REQUIREMENTS INTERFACE)
# Target with linker requirements
add_library(CXX_LINKER_REQUIREMENTS INTERFACE)
target_link_options(CXX_LINKER_REQUIREMENTS INTERFACE
- ${CXX_FLAGS}
+ ${ObjectiveProject_CXX_FLAGS}
)
target_link_libraries(CXX_LINKER_REQUIREMENTS INTERFACE
gcc
@@ -49,10 +56,14 @@ target_link_libraries(CXX_LINKER_REQUIREMENTS INTERFACE
# Set compiler flags
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang|GNU")
target_compile_options(CXX_COMPILER_REQUIREMENTS INTERFACE
- ${CXX_FLAGS}
+ ${ObjectiveProject_CXX_FLAGS}
)
endif()
+target_compile_options(ASM_NASM_COMPILER_REQUIREMENTS INTERFACE
+ ${ObjectiveProject_ASM_NASM_FLAGS}
+)
+
target_include_directories(CXX_COMPILER_REQUIREMENTS
INTERFACE
${ObjectiveProject_SOURCE_DIR}/include