From cd04b4f903f3d26a10ef12195a7e422e6ea27c6e Mon Sep 17 00:00:00 2001 From: Joan Karadimov Date: Tue, 15 Mar 2022 20:30:51 +0200 Subject: [PATCH 1/3] Correctly pass warning level to the compiler Use `add_compile_options ("-W4")` instead of `add_definitions ("-W4")` since the latter passes a `-W4` argument to `rc.exe` which results in this error: fatal error RC1106: invalid option: -4 The same is done for non-MSVC compilers for consistency and to avoid similar problems. --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index cfddbfb..7537f0b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -26,10 +26,10 @@ if (NOT MSVC) endif () if (NOT MSVC) - add_definitions ("-Wall") + add_compile_options ("-Wall") else () # Show level 4 warnings. - add_definitions ("-W4") + add_compile_options ("-W4") endif () option(UNICODE "Compile with UNICODE support" OFF) From 7508655731e9a01a6fc4fc2b0d2dbd83ce49cf56 Mon Sep 17 00:00:00 2001 From: Joan Karadimov Date: Tue, 15 Mar 2022 21:07:06 +0200 Subject: [PATCH 2/3] Only compile the test suite if TESTSUITE is defined This avoids the following linker error: unresolved external symbol _MemoryModuleTestsuite referenced in function _main --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7537f0b..33694bc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -44,6 +44,7 @@ option(TESTSUITE "Compile with TESTSUITE support" OFF) if (TESTSUITE) message (STATUS "Compile with TESTSUITE support") add_definitions ("-DTESTSUITE") + add_subdirectory (tests) else () message (STATUS "Compile without TESTSUITE support") endif () @@ -55,6 +56,5 @@ if (NOT MSVC) endif () add_subdirectory (example) -add_subdirectory (tests) enable_language (RC) From 9849b9fe1eec9ba62a3b2dd8abd97f762acab547 Mon Sep 17 00:00:00 2001 From: Joan Karadimov Date: Tue, 15 Mar 2022 21:09:36 +0200 Subject: [PATCH 3/3] Allow the examples to be disabled in the compilation --- CMakeLists.txt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 33694bc..39bf88c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -55,6 +55,9 @@ if (NOT MSVC) set_target_properties ("MemoryModule" PROPERTIES PREFIX "") endif () -add_subdirectory (example) +option(MEMORY_MODULE_EXAMPLES "Include the MemoryModule examples" ON) +if (MEMORY_MODULE_EXAMPLES) + add_subdirectory (example) +endif () enable_language (RC)