From 94a777609e4b6fffcb801bb5ea6f7070d1195732 Mon Sep 17 00:00:00 2001 From: clanmills Date: Sun, 14 Jul 2019 19:37:15 +0100 Subject: [PATCH 1/4] fix947_FreeBSD_BasicError_typeinfo --- include/exiv2/error.hpp | 2 +- src/CMakeLists.txt | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/include/exiv2/error.hpp b/include/exiv2/error.hpp index 42a0959c..bd74c449 100644 --- a/include/exiv2/error.hpp +++ b/include/exiv2/error.hpp @@ -260,7 +260,7 @@ namespace Exiv2 { provided to print errors to a stream. */ template - class BasicError : public AnyError { + class EXIV2API BasicError : public AnyError { public: //! @name Creators //@{ diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index c878008b..afd8c587 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -145,10 +145,8 @@ endif() set_target_properties( exiv2lib_int PROPERTIES POSITION_INDEPENDENT_CODE ON - COMPILE_DEFINITIONS exiv2lib_STATIC ) - target_include_directories(exiv2lib_int PRIVATE ${ZLIB_INCLUDE_DIR}) target_include_directories(exiv2lib PRIVATE ${ZLIB_INCLUDE_DIR}) From 76d279817258575d2bdb376b838f573d27025c29 Mon Sep 17 00:00:00 2001 From: Robin Mills Date: Tue, 16 Jul 2019 21:39:28 +0100 Subject: [PATCH 2/4] Pushing very helpful suggestion by @lantw44 --- include/exiv2/error.hpp | 18 +++++++++--------- src/CMakeLists.txt | 1 + src/error.cpp | 4 ++-- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/include/exiv2/error.hpp b/include/exiv2/error.hpp index bd74c449..1787f10c 100644 --- a/include/exiv2/error.hpp +++ b/include/exiv2/error.hpp @@ -265,38 +265,38 @@ namespace Exiv2 { //! @name Creators //@{ //! Constructor taking only an error code - explicit BasicError(ErrorCode code); + explicit inline BasicError(ErrorCode code); //! Constructor taking an error code and one argument template - BasicError(ErrorCode code, const A& arg1); + inline BasicError(ErrorCode code, const A& arg1); //! Constructor taking an error code and two arguments template - BasicError(ErrorCode code, const A& arg1, const B& arg2); + inline BasicError(ErrorCode code, const A& arg1, const B& arg2); //! Constructor taking an error code and three arguments template - BasicError(ErrorCode code, const A& arg1, const B& arg2, const C& arg3); + inline BasicError(ErrorCode code, const A& arg1, const B& arg2, const C& arg3); //! Virtual destructor. (Needed because of throw()) - virtual ~BasicError() throw(); + virtual inline ~BasicError() throw(); //@} //! @name Accessors //@{ - virtual int code() const throw(); + virtual inline int code() const throw(); /*! @brief Return the error message as a C-string. The pointer returned by what() is valid only as long as the BasicError object exists. */ - virtual const char* what() const throw(); + virtual inline const char* what() const throw(); #ifdef EXV_UNICODE_PATH /*! @brief Return the error message as a wchar_t-string. The pointer returned by wwhat() is valid only as long as the BasicError object exists. */ - virtual const wchar_t* wwhat() const throw(); + virtual inline const wchar_t* wwhat() const throw(); #endif //@} @@ -304,7 +304,7 @@ namespace Exiv2 { //! @name Manipulators //@{ //! Assemble the error message from the arguments - EXIV2API void setMsg(); + void setMsg(); //@} // DATA diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index afd8c587..76eaabcc 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -145,6 +145,7 @@ endif() set_target_properties( exiv2lib_int PROPERTIES POSITION_INDEPENDENT_CODE ON + COMPILE_DEFINITIONS exiv2lib_EXPORTS ) target_include_directories(exiv2lib_int PRIVATE ${ZLIB_INCLUDE_DIR}) diff --git a/src/error.cpp b/src/error.cpp index c8e2d9e0..a47db000 100644 --- a/src/error.cpp +++ b/src/error.cpp @@ -225,7 +225,7 @@ namespace Exiv2 { } template<> - void BasicError::setMsg() + void EXIV2API BasicError::setMsg() { std::string msg = _(errMsg(code_)); std::string::size_type pos; @@ -262,7 +262,7 @@ namespace Exiv2 { #ifdef EXV_UNICODE_PATH template<> - void BasicError::setMsg() + void EXIV2API BasicError::setMsg() { std::string s = _(errMsg(code_)); std::wstring wmsg(s.begin(), s.end()); From 0c282f8373f81ba82c8a346a9f6e82bd467a2660 Mon Sep 17 00:00:00 2001 From: Robin Mills Date: Wed, 17 Jul 2019 16:25:47 +0100 Subject: [PATCH 3/4] Looking better all the time, Gentlemen. I believe the only changes between the patches are in unitTests/CMakeLists.txt. This build passes the test suite and jens.cpp on MacOS-X. I'll submit and see what the CI has to say. With the changes only relating to unitTests (which I didn't run on FreeBSD), we should not have disturbed Linux/FreeBSD/jens.cpp. --- unitTests/CMakeLists.txt | 34 +++++++++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/unitTests/CMakeLists.txt b/unitTests/CMakeLists.txt index 6dbee160..215118c9 100644 --- a/unitTests/CMakeLists.txt +++ b/unitTests/CMakeLists.txt @@ -1,5 +1,22 @@ find_package(GTest REQUIRED) +get_target_property(exiv2lib_SOURCES exiv2lib SOURCES) +get_target_property(exiv2lib_int_SOURCES exiv2lib_int SOURCES) +get_target_property(exiv2lib_COMPILE_DEFINITIONS exiv2lib COMPILE_DEFINITIONS) +get_target_property(exiv2lib_INCLUDE_DIRECTORIES exiv2lib INCLUDE_DIRECTORIES) +get_target_property(exiv2lib_LINK_LIBRARIES exiv2lib LINK_LIBRARIES) + +set(unit_tests_exiv2lib_SOURCES) +foreach(source IN LISTS exiv2lib_SOURCES exiv2lib_int_SOURCES) + if(source MATCHES "\.(c|cpp|h|hpp)$") + if(source MATCHES ".*/.*") + list(APPEND unit_tests_exiv2lib_SOURCES "${source}") + else() + list(APPEND unit_tests_exiv2lib_SOURCES "../src/${source}") + endif() + endif() +endforeach() + add_executable(unit_tests mainTestRunner.cpp gtestwrapper.h test_types.cpp @@ -14,13 +31,24 @@ add_executable(unit_tests mainTestRunner.cpp test_helper_functions.cpp test_slice.cpp test_image_int.cpp - $ + ${unit_tests_exiv2lib_SOURCES} +) + +target_compile_definitions(unit_tests + PRIVATE + exiv2lib_STATIC + ${exiv2lib_COMPILE_DEFINITIONS} +) + +target_include_directories(unit_tests + PRIVATE + ${exiv2lib_INCLUDE_DIRECTORIES} ) #TODO Use GTest::GTest once we upgrade the minimum CMake version required target_link_libraries(unit_tests PRIVATE - exiv2lib + ${exiv2lib_LINK_LIBRARIES} ${GTEST_BOTH_LIBRARIES} ) @@ -50,4 +78,4 @@ endif() if (MSVC) set_target_properties(unit_tests PROPERTIES LINK_FLAGS "/ignore:4099") -endif() \ No newline at end of file +endif() From 0058dd1099e9f9032535e00a215ca513d8ad4a23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20D=C3=ADaz=20M=C3=A1s?= Date: Wed, 17 Jul 2019 22:34:15 +0200 Subject: [PATCH 4/4] Use compile definitions only if they are available --- unitTests/CMakeLists.txt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/unitTests/CMakeLists.txt b/unitTests/CMakeLists.txt index 215118c9..6b73d81d 100644 --- a/unitTests/CMakeLists.txt +++ b/unitTests/CMakeLists.txt @@ -34,11 +34,11 @@ add_executable(unit_tests mainTestRunner.cpp ${unit_tests_exiv2lib_SOURCES} ) -target_compile_definitions(unit_tests - PRIVATE - exiv2lib_STATIC - ${exiv2lib_COMPILE_DEFINITIONS} -) +target_compile_definitions(unit_tests PRIVATE exiv2lib_STATIC) + +if (exiv2lib_COMPILE_DEFINITIONS) + target_compile_definitions(unit_tests PRIVATE ${exiv2lib_COMPILE_DEFINITIONS}) +endif () target_include_directories(unit_tests PRIVATE