From ac37076327e8d38a0aafc4b4c2ea506c708edfaf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20Sch=C3=B6nle?= Date: Wed, 17 May 2017 22:24:11 +0200 Subject: [PATCH] Cross-compiling: Version readout fixed (#189) * Cross-comoiling: Version readout fixed Test.cmake: Path handling consistent * ".x" syntax in variable checking removed * Use G3LOG_DEBUG also in linux-specific code * Fixed error when linux and shared library is on * Fixed linux/windows shared lib handling: FATAL_ERROR for wrong cmake version and no message in linux --- Build.cmake | 10 ++++++---- CMakeLists.txt | 4 ++-- test_unit/Test.cmake | 2 +- test_unit/tester_sharedlib.cpp | 8 +------- 4 files changed, 10 insertions(+), 14 deletions(-) diff --git a/Build.cmake b/Build.cmake index e080360..514ecc9 100644 --- a/Build.cmake +++ b/Build.cmake @@ -107,10 +107,12 @@ ENDIF() SET(G3LOG_LIBRARY g3logger) IF( G3_SHARED_LIB ) - IF(NOT(CMAKE_VERSION LESS 3.4)) - set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) - ELSE() - message( FATAL "Need CMake version >=3.4 to build shared windows library!" ) + IF( WIN32 ) + IF(NOT(CMAKE_VERSION LESS 3.4)) + set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) + ELSE() + message( FATAL_ERROR "Need CMake version >=3.4 to build shared windows library!" ) + ENDIF() ENDIF() ADD_LIBRARY(${G3LOG_LIBRARY} SHARED ${SRC_FILES}) ELSE() diff --git a/CMakeLists.txt b/CMakeLists.txt index 089b56f..d999fcd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -71,8 +71,8 @@ endif() SET(MAJOR_VERSION 1) -IF (${VERSION}.x STREQUAL ".x") - IF (MSVC) +IF ( NOT VERSION ) + IF ( "${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "Windows" ) message("windows: Extracting git software version") execute_process(COMMAND powershell "(git rev-list --branches HEAD | Measure-Object -line).Lines" OUTPUT_VARIABLE GIT_VERSION WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}) ELSE() diff --git a/test_unit/Test.cmake b/test_unit/Test.cmake index 078a3e2..6acaf3c 100644 --- a/test_unit/Test.cmake +++ b/test_unit/Test.cmake @@ -74,7 +74,7 @@ add_library(tester_sharedlib SHARED ${DIR_UNIT_TEST}/tester_sharedlib.h ${DIR_UNIT_TEST}/tester_sharedlib.cpp) target_link_libraries(tester_sharedlib ${G3LOG_LIBRARY}) - add_executable(test_dynamic_loaded_shared_lib ../test_main/test_main.cpp ${DIR_UNIT_TEST}/test_linux_dynamic_loaded_sharedlib.cpp) + add_executable(test_dynamic_loaded_shared_lib ${g3log_SOURCE_DIR}/test_main/test_main.cpp ${DIR_UNIT_TEST}/test_linux_dynamic_loaded_sharedlib.cpp) set_target_properties(test_dynamic_loaded_shared_lib PROPERTIES COMPILE_DEFINITIONS "GTEST_HAS_TR1_TUPLE=0") set_target_properties(test_dynamic_loaded_shared_lib PROPERTIES COMPILE_DEFINITIONS "GTEST_HAS_RTTI=0") target_link_libraries(test_dynamic_loaded_shared_lib ${G3LOG_LIBRARY} -ldl gtest_170_lib ) diff --git a/test_unit/tester_sharedlib.cpp b/test_unit/tester_sharedlib.cpp index 934b5ff..000ce68 100644 --- a/test_unit/tester_sharedlib.cpp +++ b/test_unit/tester_sharedlib.cpp @@ -11,12 +11,6 @@ #include #include "tester_sharedlib.h" -#if (defined(CHANGE_G3LOG_DEBUG_TO_DBUG)) -#define DEBUG_NAME DBUG -#else -#define DEBUG_NAME DEBUG -#endif - struct RuntimeLoadedLib : public SomeLibrary { RuntimeLoadedLib() { @@ -25,7 +19,7 @@ struct RuntimeLoadedLib : public SomeLibrary { } ~RuntimeLoadedLib() { - LOG(DEBUG_NAME) << "Library destroyed"; + LOG(G3LOG_DEBUG) << "Library destroyed"; } void action() {