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)
