Files
r8asm_rev-fork/CMakeLists.txt
T
starcells f68d68d497 build: stop throwing the compiler's default flags away
set(CMAKE_CXX_FLAGS ...) replaced the whole flag set.  On MSVC that
dropped /EHsc, which this code needs (std::map::at, std::stoi throw), and
it applied -O3 to every configuration -- a Debug build then passes /RTC1
and MSVC refuses to combine that with an optimisation level (D8016).

CMake's Release configuration already passes -O3 / /O2 and defines
NDEBUG, so the block is gone.  The only flag worth keeping is
-march=native, and only for a Release build of a non-MSVC compiler.

Also cast the cell-size constants so the size_t -> int32_t narrowing
warnings go away.
2026-11-05 22:49:54 +08:00

25 lines
805 B
CMake

cmake_minimum_required(VERSION 3.10)
project(R8ASM)
set(CMAKE_CXX_STANDARD 20)
include_directories(include)
add_library(r8asm_core src/r8asm.cc)
# The old line here was
# set(CMAKE_CXX_FLAGS "-O3 -march=native -DNDEBUG")
# which replaced CMake's whole flag set: on MSVC that drops /EHsc (this
# code uses std::map::at, std::stoi and friends) and it also pushed -O3 into
# Debug builds, where MSVC's /RTC1 and /O2 refuse to coexist (D8016).
#
# CMake's own Release configuration already passes -O3 / /O2 and defines
# NDEBUG, so the only thing worth keeping is -march=native, and only for a
# release build of a non-MSVC compiler.
if(NOT MSVC)
add_compile_options($<$<CONFIG:Release>:-march=native>)
endif()
add_executable(r8asm_test tests/r8_test.cc)
target_link_libraries(r8asm_test r8asm_core)