From c43d3531cdfd99bfd055ceb8188b5775a77f9ac4 Mon Sep 17 00:00:00 2001 From: Throughflow <91414345+Throughflow@users.noreply.github.com> Date: Sun, 26 Sep 2021 03:44:49 -0700 Subject: [PATCH 1/2] Add support for Visual Studio compilation using vcpkg for dependencies --- .gitignore | 3 +++ BUILD.md | 4 ++-- CMakeLists.txt | 8 ++++---- src/dec/registry.h | 1 + src/logger_win.cc | 1 + 5 files changed, 11 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index 8d85ff40e..df64a0639 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,6 @@ *.so *~ /build +/out +/.vs +CMakeSettings.json \ No newline at end of file diff --git a/BUILD.md b/BUILD.md index f0cc53224..2f2c922c1 100644 --- a/BUILD.md +++ b/BUILD.md @@ -101,8 +101,8 @@ variable): -DJPEG_INCLUDE_DIR="C:/pkg/libjpeg-turbo/include" \ -DOPENSSL_ROOT_DIR="C:/pkg/OpenSSL-Win32" \ -DOPENSSL_INCLUDE_DIR="C:/pkg/OpenSSL-Win32/include" \ - -DICONV_LIBRARY="C:/pkg/win-iconv/build/Debug/iconv.lib" \ - -DICONV_INCLUDE_DIR="C:/pkg/win-iconv" \ + -DIconv_LIBRARIES="C:/pkg/win-iconv/build/Debug/iconv.lib" \ + -DIconv_INCLUDE_DIRS="C:/pkg/win-iconv" \ .. The paths in `-D` switches should refer to locations where you installed diff --git a/CMakeLists.txt b/CMakeLists.txt index 2453f2f64..0aeb35480 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -39,7 +39,7 @@ find_package(OpenSSL REQUIRED) include_directories(${OPENSSL_INCLUDE_DIR}) link_directories(${OPENSSL_LIBRARY_DIRS}) -find_package(WebP) +find_package(WEBP) include_directories(${WEBP_INCLUDE_DIR}) link_directories(${WEBP_LIBRARY_DIRS}) @@ -90,7 +90,6 @@ endif() configure_file("${CMAKE_SOURCE_DIR}/src/version.h.in" "${CMAKE_BINARY_DIR}/generated/version.h" @ONLY) include_directories(${CMAKE_BINARY_DIR}/generated) -set(CMAKE_SOURCE_DIR "${CMAKE_BINARY_DIR}/../") file(GLOB_RECURSE au_sources "${CMAKE_SOURCE_DIR}/src/*.cc") file(GLOB_RECURSE au_headers "${CMAKE_SOURCE_DIR}/src/*.h") file(GLOB_RECURSE test_sources "${CMAKE_SOURCE_DIR}/tests/*.cc") @@ -175,9 +174,10 @@ if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX) elseif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") set(iconv iconv) else() - set(iconv ${ICONV_LIBRARY}) + find_package(Iconv REQUIRED) + set(iconv ${Iconv_LIBRARIES}) set(unicode "") - include_directories(${ICONV_INCLUDE_DIR}) + include_directories(${Iconv_INCLUDE_DIRS}) endif() add_library(libau OBJECT ${au_sources} ${au_headers}) diff --git a/src/dec/registry.h b/src/dec/registry.h index 74e95b399..76048bc6f 100644 --- a/src/dec/registry.h +++ b/src/dec/registry.h @@ -20,6 +20,7 @@ #include #include #include +#include namespace au { namespace dec { diff --git a/src/logger_win.cc b/src/logger_win.cc index bee6cefb4..77f5d579e 100644 --- a/src/logger_win.cc +++ b/src/logger_win.cc @@ -17,6 +17,7 @@ #include "logger.h" #include +#include using namespace au; From d539fc295b8bfc0e895bfee4228175dbe15e822f Mon Sep 17 00:00:00 2001 From: Throughflow <91414345+Throughflow@users.noreply.github.com> Date: Sun, 26 Sep 2021 03:45:25 -0700 Subject: [PATCH 2/2] Make the test suite optional --- CMakeLists.txt | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0aeb35480..abbd666f0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,6 +4,11 @@ set(CMAKE_CXX_STANDARD 14) set(CMAKE_CXX_STANDARD_REQUIRED on) set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/src/cmake") +# ------- +# Options +# ------- +option(BUILD_TESTS "Build test programs" OFF) + # ------- # Version # ------- @@ -188,16 +193,19 @@ if(WEBP_FOUND) target_link_libraries(arc_unpacker ${WEBP_LIBRARIES}) endif() -add_executable(run_tests ${test_sources} ${test_headers} "${CMAKE_SOURCE_DIR}/tests/main.cc" $) -target_link_libraries(run_tests ${iconv} ${Boost_LIBRARIES} ${ZLIB_LIBRARIES} ${PNG_LIBRARIES} ${JPEG_LIBRARIES} ${OPENSSL_LIBRARIES}) -if(WEBP_FOUND) - target_link_libraries(run_tests ${WEBP_LIBRARIES}) -endif() - target_include_directories(libau BEFORE PUBLIC "${CMAKE_SOURCE_DIR}/src") target_include_directories(libau BEFORE PUBLIC "${CMAKE_BINARY_DIR}/generated") target_include_directories(arc_unpacker BEFORE PUBLIC "${CMAKE_SOURCE_DIR}/src") target_include_directories(arc_unpacker BEFORE PUBLIC "${CMAKE_BINARY_DIR}/generated") -target_include_directories(run_tests BEFORE PUBLIC "${CMAKE_SOURCE_DIR}/src") -target_include_directories(run_tests BEFORE PUBLIC "${CMAKE_SOURCE_DIR}/tests") -target_include_directories(run_tests BEFORE PUBLIC "${CMAKE_BINARY_DIR}/generated") + +if (BUILD_TESTS) + add_executable(run_tests ${test_sources} ${test_headers} "${CMAKE_SOURCE_DIR}/tests/main.cc" $) + target_link_libraries(run_tests ${iconv} ${Boost_LIBRARIES} ${ZLIB_LIBRARIES} ${PNG_LIBRARIES} ${JPEG_LIBRARIES} ${OPENSSL_LIBRARIES}) + if(WEBP_FOUND) + target_link_libraries(run_tests ${WEBP_LIBRARIES}) + endif() + + target_include_directories(run_tests BEFORE PUBLIC "${CMAKE_SOURCE_DIR}/src") + target_include_directories(run_tests BEFORE PUBLIC "${CMAKE_SOURCE_DIR}/tests") + target_include_directories(run_tests BEFORE PUBLIC "${CMAKE_BINARY_DIR}/generated") +endif()