This is an automated email from the ASF dual-hosted git repository.

abroekhuis pushed a commit to branch feature/support_multiple_build_types
in repository https://gitbox.apache.org/repos/asf/celix.git


The following commit(s) were added to 
refs/heads/feature/support_multiple_build_types by this push:
     new 5bc6333  Restructured compile flags. Update test bundle filenames to 
work with build type.
5bc6333 is described below

commit 5bc6333fde6da4b6bd665fb11695babf6d6e9e36
Author: Alexander Broekhuis <[email protected]>
AuthorDate: Thu May 7 20:47:05 2020 +0200

    Restructured compile flags.
    Update test bundle filenames to work with build type.
---
 CMakeLists.txt                                     | 60 +++++++++++++---------
 libs/framework/gtest/CMakeLists.txt                |  3 ++
 .../gtest/src/bundle_context_bundles_tests.cpp     | 14 ++---
 3 files changed, 47 insertions(+), 30 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 15732a3..80b940d 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -15,7 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
-cmake_minimum_required (VERSION 3.2)
+cmake_minimum_required (VERSION 3.14)
 cmake_policy(SET CMP0012 NEW)
 cmake_policy(SET CMP0042 NEW)
 if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.9.0")
@@ -32,27 +32,35 @@ IF (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} EQUAL 3.3 
AND ${CMAKE_GENERATO
     message( FATAL_ERROR "Building Celix using CMake 3.3 and makefiles is not 
supported due to a bug in the Makefile Generator (see Bug 15696). Please change 
the used CMake version - both, CMake 3.2 and CMake 3.4 are working fine. Or use 
a different generator (e.g. Ninja)." )
 ENDIF()
 
-set(ENABLE_W_ERROR ON)
 set(ENABLE_MORE_WARNINGS OFF)
 
-IF (ANDROID)
-    set(CMAKE_C_FLAGS "-D_GNU_SOURCE -std=gnu99 -Wall ${CMAKE_C_FLAGS}")
-ELSE ()
-    set(CMAKE_C_FLAGS "-D_GNU_SOURCE -std=gnu99 -fPIC ${CMAKE_C_FLAGS}")
-    set(CMAKE_CXX_FLAGS "-std=c++11 -fno-rtti ${CMAKE_CXX_FLAGS}")
-    set(CMAKE_C_FLAGS "-Wall -Werror -Wno-nullability-completeness 
-Wno-expansion-to-defined ${CMAKE_C_FLAGS}")
-    set(CMAKE_CXX_FLAGS "-Wall -Wextra -Weffc++ ${CMAKE_CXX_FLAGS}")
-    set(CMAKE_C_FLAGS_DEBUG "-g -DDEBUG ${CMAKE_C_FLAGS}")
-    set(CMAKE_CXX_FLAGS_DEBUG "-g -DDEBUG ${CMAKE_CXX_FLAGS}")
-ENDIF()
+# Set C specific flags
+set(CMAKE_C_FLAGS "-D_GNU_SOURCE -std=gnu99 -fPIC ${CMAKE_C_FLAGS}")
+set(CMAKE_C_FLAGS "-Wall -Werror ${CMAKE_C_FLAGS}")
+
+# Set C++ specific flags
+set(CMAKE_CXX_FLAGS "-std=c++11 -fno-rtti ${CMAKE_CXX_FLAGS}")
+set(CMAKE_CXX_FLAGS "-Wall -Werror -Wextra -Weffc++ ${CMAKE_CXX_FLAGS}")
 
-IF(APPLE)
+if(APPLE)
     set(CMAKE_MACOSX_RPATH 1)
-ELSE ()
+endif()
+
+if(NOT APPLE)
     set(CMAKE_C_FLAGS "-pthread ${CMAKE_C_FLAGS}")
     set(CMAKE_CXX_FLAGS "-pthread ${CMAKE_CXX_FLAGS}")
     set(CMAKE_EXE_LINKER_FLAGS "-pthread ${CMAKE_EXE_LINKER_FLAGS}")
-ENDIF()
+endif()
+
+# Set compiler specific options
+if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
+    set(CMAKE_C_FLAGS "-Wno-nullability-completeness -Wno-expansion-to-defined 
${CMAKE_C_FLAGS}")
+endif()
+
+if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
+    set(CMAKE_C_FLAGS "-Wno-unused-result -Wno-format-truncation 
-Wno-stringop-truncation -Wno-stringop-overflow ${CMAKE_C_FLAGS}")
+    set(CMAKE_CXX_FLAGS "-Wno-unused-result -Wno-format-truncation 
-Wno-stringop-truncation -Wno-stringop-overflow ${CMAKE_CXX_FLAGS}")
+endif()
 
 if (ENABLE_MORE_WARNINGS)
     if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
@@ -75,15 +83,23 @@ if (ENABLE_MORE_WARNINGS)
             set(CMAKE_CXX_EXTRA_FLAGS "-Wold-style-cast -Wuseless-cast 
${CMAKE_CXX_EXTRA_FLAGS}")
         endif()
     endif()
-    
+
     set(CMAKE_CXX_FLAGS "${CMAKE_CXX_EXTRA_FLAGS} ${CMAKE_CXX_FLAGS}")
-    set(CMAKE_CXX_FLAGS_DEBUG "-Werror ${CMAKE_CXX_EXTRA_FLAGS} 
${CMAKE_CXX_FLAGS_DEBUG}")
 endif()
 
-if(ENABLE_W_ERROR)
-    set(CMAKE_CXX_FLAGS "-Werror ${CMAKE_CXX_FLAGS}")
-    set(CMAKE_CXX_FLAGS_DEBUG "-Werror ${CMAKE_CXX_FLAGS_DEBUG}")
-endif()
+# Set build type specific flags
+# Debug Address + Undefined
+set(CMAKE_C_FLAGS_DEBUG "-g -DDEBUG ${CMAKE_C_FLAGS}")
+set(CMAKE_CXX_FLAGS_DEBUG "-g -DDEBUG ${CMAKE_CXX_FLAGS}")
+set(CMAKE_DEBUG_POSTFIX "d")
+
+# Release with debug info
+set(CMAKE_C_FLAGS_RELWITHDEBINFO "-O0 -g -DNDEBUG ${CMAKE_C_FLAGS}")
+set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O0 -g -DNDEBUG ${CMAKE_CXX_FLAGS}")
+
+# Release
+set(CMAKE_C_FLAGS_RELEASE "-O0 -DNDEBUG ${CMAKE_C_FLAGS}")
+set(CMAKE_CXX_FLAGS_RELEASE "-O0 -DNDEBUG ${CMAKE_CXX_FLAGS}")
 
 # Set version for the framework package/release
 set(CELIX_MAJOR "2")
@@ -93,8 +109,6 @@ set(CELIX_MICRO "0")
 # Default bundle version
 set(DEFAULT_VERSION 1.0.0)
 
-set(CMAKE_DEBUG_POSTFIX "d")
-
 # Options
 option(ENABLE_TESTING "Enables unit/bundle testing" FALSE)
 if (ENABLE_TESTING)
diff --git a/libs/framework/gtest/CMakeLists.txt 
b/libs/framework/gtest/CMakeLists.txt
index 130eaf1..d686297 100644
--- a/libs/framework/gtest/CMakeLists.txt
+++ b/libs/framework/gtest/CMakeLists.txt
@@ -15,6 +15,9 @@
 # specific language governing permissions and limitations
 # under the License.
 
+# Set buildtype as define so that in the test code we can use the proper 
bundle names
+add_definitions ( -DBUILD_TYPE=\"${CMAKE_BUILD_TYPE}\" )
+
 add_celix_bundle(simple_test_bundle1 NO_ACTIVATOR VERSION 1.0.0)
 add_celix_bundle(simple_test_bundle2 NO_ACTIVATOR VERSION 1.0.0)
 add_celix_bundle(simple_test_bundle3 NO_ACTIVATOR VERSION 1.0.0)
diff --git a/libs/framework/gtest/src/bundle_context_bundles_tests.cpp 
b/libs/framework/gtest/src/bundle_context_bundles_tests.cpp
index 7295367..d30d7ea 100644
--- a/libs/framework/gtest/src/bundle_context_bundles_tests.cpp
+++ b/libs/framework/gtest/src/bundle_context_bundles_tests.cpp
@@ -35,13 +35,13 @@ public:
     celix_bundle_context_t *ctx = nullptr;
     celix_properties_t *properties = nullptr;
 
-    const char * const TEST_BND1_LOC = "simple_test_bundle1.zip";
-    const char * const TEST_BND2_LOC = "simple_test_bundle2.zip";
-    const char * const TEST_BND3_LOC = "simple_test_bundle3.zip";
-    const char * const TEST_BND4_LOC = "simple_test_bundle4.zip";
-    const char * const TEST_BND5_LOC = "simple_test_bundle5.zip";
-    const char * const TEST_BND_WITH_EXCEPTION_LOC = 
"bundle_with_exception.zip";
-    const char * const TEST_BND_UNRESOLVEABLE_LOC = "unresolveable_bundle.zip";
+    const char * const TEST_BND1_LOC = "simple_test_bundle1-" BUILD_TYPE 
".zip";
+    const char * const TEST_BND2_LOC = "simple_test_bundle2-" BUILD_TYPE 
".zip";
+    const char * const TEST_BND3_LOC = "simple_test_bundle3-" BUILD_TYPE 
".zip";
+    const char * const TEST_BND4_LOC = "simple_test_bundle4-" BUILD_TYPE 
".zip";
+    const char * const TEST_BND5_LOC = "simple_test_bundle5-" BUILD_TYPE 
".zip";
+    const char * const TEST_BND_WITH_EXCEPTION_LOC = "bundle_with_exception-" 
BUILD_TYPE ".zip";
+    const char * const TEST_BND_UNRESOLVEABLE_LOC = "unresolveable_bundle-" 
BUILD_TYPE ".zip";
 
     CelixBundleContextBundlesTests() {
         properties = properties_create();

Reply via email to