summaryrefslogtreecommitdiff
path: root/CMakeLists.txt
diff options
context:
space:
mode:
authorOxore <oxore@protonmail.com>2024-02-18 21:18:23 +0300
committerOxore <oxore@protonmail.com>2024-02-18 21:18:23 +0300
commitfec4c1684e8680285f51ebd4898fe35127c7e098 (patch)
tree62d4191931edd6584c77049d0ca653005065fc8d /CMakeLists.txt
parent21a9aa92a7cf8767a0fcb33858546dea744c4071 (diff)
Refactor CMakeLists.txt and fix new warnings
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt54
1 files changed, 35 insertions, 19 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 13c67a2..a778958 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -8,30 +8,46 @@ set(CMAKE_CXX_STANDARD_REQUIRED True)
set(CMAKE_C_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED True)
set(CMAKE_EXPORT_COMPILE_COMMANDS True)
-set(common_flags)
-set(common_debug_flags "-fsanitize=address -fno-omit-frame-pointer -O1")
-# Uncomment to enalbe profiler
-#set(common_debug_flags "${common_debug_flags} -pg")
-set(common_compile_flags "-Wall -Wextra -pedantic")
-set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${common_compile_flags} ${common_flags}")
-set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} ${common_debug_flags}")
-set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${common_compile_flags} ${common_flags}")
-# Speed up compilation with -fno-exceptions and -fno-rtti
-set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-exceptions -fno-rtti -Wno-nested-anon-types")
-set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${common_debug_flags}")
-set(CMAKE_LINKER_FLAGS "${CMAKE_LINKER_FLAGS} ${common_flags}")
-set(CMAKE_LINKER_FLAGS_DEBUG "${CMAKE_LINKER_FLAGS_DEBUG} ${common_debug_flags}")
-set(m68kdisasm_sources
+set(common_debug_flags
+ -fsanitize=address,undefined
+ -fno-omit-frame-pointer
+ -O1
+ -g3
+ # Uncomment to enable profiler
+ # -pg
+ )
+
+add_executable(m68k-disasm
src/main.cpp
src/data_buffer.cpp
src/disasm.cpp
src/elf_image.cpp
)
-add_executable(m68k-disasm ${m68kdisasm_sources})
-
-include_directories(
- .
- lib
+target_compile_options(m68k-disasm PRIVATE
+ $<$<CONFIG:Debug>:${common_debug_flags}>
+ $<$<COMPILE_LANGUAGE:C>:-Wno-nested-anon-types>
+ # Speed up compilation with -fno-exceptions and -fno-rtti
+ $<$<COMPILE_LANGUAGE:CXX>:-fno-exceptions>
+ $<$<COMPILE_LANGUAGE:CXX>:-fno-rtti>
+ $<$<COMPILE_LANGUAGE:CXX>:-Wold-style-cast>
+ $<$<COMPILE_LANGUAGE:CXX>:-Wsuggest-override>
+ $<$<COMPILE_LANG_AND_ID:CXX,GNU>:-Wsuggest-final-types>
+ $<$<COMPILE_LANG_AND_ID:CXX,GNU>:-Wsuggest-final-methods>
+ $<$<COMPILE_LANG_AND_ID:CXX,GNU>:-fstrict-volatile-bitfields>
+ $<$<COMPILE_LANG_AND_ID:C,GNU>:-fstrict-volatile-bitfields>
+ $<$<COMPILE_LANG_AND_ID:CXX,GNU>:-Wlogical-op>
+ $<$<COMPILE_LANG_AND_ID:C,GNU>:-Wlogical-op>
+ $<$<COMPILE_LANG_AND_ID:CXX,GNU>:-ffile-prefix-map=${CMAKE_SOURCE_DIR}/=>
+ $<$<COMPILE_LANG_AND_ID:C,GNU>:-ffile-prefix-map=${CMAKE_SOURCE_DIR}/=>
+ -Wall
+ -Wextra
+ -pedantic
+ -Wcast-align
+ -Wshadow
)
+
+target_compile_definitions(m68k-disasm PRIVATE $<$<CONFIG:Debug>:_FORTIFY_SOURCE=2>)
+target_link_options(m68k-disasm PRIVATE $<$<CONFIG:Debug>:${common_debug_flags}>)
+target_include_directories(m68k-disasm PRIVATE . lib)