From 43c9ec0f5095d92e2dd748c6c0b6f7ae4e6c73bf Mon Sep 17 00:00:00 2001 From: Kevin Backhouse Date: Mon, 16 Jan 2023 10:33:25 +0000 Subject: [PATCH] Add EXIV2_ENABLE_INIH flag to enable building without libinih. --- CMakeLists.txt | 1 + cmake/config.h.cmake | 3 +++ cmake/findDependencies.cmake | 12 +++++++----- cmake/generateConfigFile.cmake | 1 + samples/CMakeLists.txt | 6 ++++-- src/CMakeLists.txt | 10 ++++++---- src/makernote_int.cpp | 4 ++++ unitTests/CMakeLists.txt | 6 ++++-- 8 files changed, 30 insertions(+), 13 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2bc05787..625e78b4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -31,6 +31,7 @@ option( EXIV2_ENABLE_CURL "Use libcurl for HttpIo (WEBREADY)" option( EXIV2_ENABLE_BMFF "Build with BMFF support" ON ) option( EXIV2_ENABLE_BROTLI "Use Brotli for JPEG XL compressed boxes (BMFF)" ON ) option( EXIV2_ENABLE_VIDEO "Build with video support" OFF ) +option( EXIV2_ENABLE_INIH "Use inih library" ON ) option( EXIV2_BUILD_SAMPLES "Build sample applications" OFF ) option( EXIV2_BUILD_EXIV2_COMMAND "Build exiv2 command-line executable" ON ) diff --git a/cmake/config.h.cmake b/cmake/config.h.cmake index 8d892b32..581defda 100644 --- a/cmake/config.h.cmake +++ b/cmake/config.h.cmake @@ -21,6 +21,9 @@ // Define if you want BMFF support. #cmakedefine EXV_ENABLE_BMFF +// Define if you want to use the inih library. +#cmakedefine EXV_ENABLE_INIH + // Define if you have the strerror_r function. #cmakedefine EXV_HAVE_STRERROR_R diff --git a/cmake/findDependencies.cmake b/cmake/findDependencies.cmake index 1e2cff1d..1075c303 100644 --- a/cmake/findDependencies.cmake +++ b/cmake/findDependencies.cmake @@ -76,11 +76,13 @@ if( ICONV_FOUND ) message ( "-- Iconv_LIBRARIES : " ${Iconv_LIBRARIES} ) endif() -find_package(inih) -message ( "-- inih_INCLUDE_DIRS : " ${inih_INCLUDE_DIRS} ) -message ( "-- inih_LIBRARIES : " ${inih_LIBRARIES} ) -message ( "-- inih_inireader_INCLUDE_DIRS : " ${inih_inireader_INCLUDE_DIRS} ) -message ( "-- inih_inireader_LIBRARIES : " ${inih_inireader_LIBRARIES} ) +if( EXIV2_ENABLE_INIH ) + find_package(inih) + message ( "-- inih_INCLUDE_DIRS : " ${inih_INCLUDE_DIRS} ) + message ( "-- inih_LIBRARIES : " ${inih_LIBRARIES} ) + message ( "-- inih_inireader_INCLUDE_DIRS : " ${inih_inireader_INCLUDE_DIRS} ) + message ( "-- inih_inireader_LIBRARIES : " ${inih_inireader_LIBRARIES} ) +endif() if( BUILD_WITH_CCACHE ) find_program(CCACHE_FOUND ccache) diff --git a/cmake/generateConfigFile.cmake b/cmake/generateConfigFile.cmake index 8047b472..a89fff60 100644 --- a/cmake/generateConfigFile.cmake +++ b/cmake/generateConfigFile.cmake @@ -9,6 +9,7 @@ endif() set(EXV_ENABLE_BMFF ${EXIV2_ENABLE_BMFF}) set(EXV_ENABLE_WEBREADY ${EXIV2_ENABLE_WEBREADY}) set(EXV_HAVE_LENSDATA ${EXIV2_ENABLE_LENSDATA}) +set(EXV_ENABLE_INIH ${EXIV2_ENABLE_INIH}) set(EXV_PACKAGE_NAME ${PROJECT_NAME}) set(EXV_PACKAGE_VERSION ${PROJECT_VERSION}) diff --git a/samples/CMakeLists.txt b/samples/CMakeLists.txt index a6c36f32..27266f28 100644 --- a/samples/CMakeLists.txt +++ b/samples/CMakeLists.txt @@ -72,8 +72,10 @@ target_include_directories(path-test PRIVATE install( TARGETS metacopy RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) -target_link_libraries( ini-test PRIVATE inih::libinih ) -target_link_libraries( ini-test PRIVATE inih::inireader ) +if( EXIV2_ENABLE_INIH ) + target_link_libraries( ini-test PRIVATE inih::libinih ) + target_link_libraries( ini-test PRIVATE inih::inireader ) +endif() if( EXPAT_FOUND ) add_executable( geotag geotag.cpp) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index df299fec..f2afb4fb 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -260,10 +260,12 @@ if( ICONV_FOUND ) target_link_libraries( exiv2lib PRIVATE Iconv::Iconv ) endif() -target_link_libraries( exiv2lib_int PRIVATE inih::libinih ) -target_link_libraries( exiv2lib_int PRIVATE inih::inireader ) -target_link_libraries( exiv2lib PRIVATE inih::libinih ) -target_link_libraries( exiv2lib PRIVATE inih::inireader ) +if( EXIV2_ENABLE_INIH ) + target_link_libraries( exiv2lib_int PRIVATE inih::libinih ) + target_link_libraries( exiv2lib_int PRIVATE inih::inireader ) + target_link_libraries( exiv2lib PRIVATE inih::libinih ) + target_link_libraries( exiv2lib PRIVATE inih::inireader ) +endif() write_basic_package_version_file(exiv2ConfigVersion.cmake COMPATIBILITY ExactVersion) diff --git a/src/makernote_int.cpp b/src/makernote_int.cpp index 0c243975..c708a39a 100644 --- a/src/makernote_int.cpp +++ b/src/makernote_int.cpp @@ -15,7 +15,9 @@ #include "utils.hpp" // + standard includes +#ifdef EXV_ENABLE_INIH #include +#endif #include #include #include @@ -81,10 +83,12 @@ std::string getExiv2ConfigPath() { std::string readExiv2Config(const std::string& section, const std::string& value, const std::string& def) { std::string result = def; +#ifdef EXV_ENABLE_INIH INIReader reader(Exiv2::Internal::getExiv2ConfigPath()); if (reader.ParseError() == 0) { result = reader.Get(section, value, def); } +#endif return result; } diff --git a/unitTests/CMakeLists.txt b/unitTests/CMakeLists.txt index 74d52f51..88a61e3f 100644 --- a/unitTests/CMakeLists.txt +++ b/unitTests/CMakeLists.txt @@ -48,10 +48,12 @@ target_link_libraries(unit_tests GTest::gtest GTest::gtest_main std::filesystem - inih::libinih - inih::inireader ) +if( EXIV2_ENABLE_INIH ) + target_link_libraries(unit_tests PRIVATE inih::libinih inih::inireader) +endif() + # ZLIB is used in exiv2lib_int. if( EXIV2_ENABLE_PNG ) target_link_libraries(unit_tests PRIVATE ${ZLIB_LIBRARIES} )