Skip to content
This repository has been archived by the owner on Apr 25, 2022. It is now read-only.

Add support for Visual Studio compilation using vcpkg for dependencies #196

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@
*.so
*~
/build
/out
/.vs
CMakeSettings.json
4 changes: 2 additions & 2 deletions BUILD.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
34 changes: 21 additions & 13 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
# -------
Expand Down Expand Up @@ -39,7 +44,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})

Expand Down Expand Up @@ -90,7 +95,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}/../")
Copy link
Author

@ghost ghost Sep 26, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure why this line was added in the first place, but it is problematic because Visual Studio places the binary directory several levels deeper. It's also completely redundant as far as I can see.

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")
Expand Down Expand Up @@ -175,9 +179,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})
Expand All @@ -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_OBJECTS:libau>)
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_OBJECTS:libau>)
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()
1 change: 1 addition & 0 deletions src/dec/registry.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include <functional>
#include <memory>
#include <vector>
#include <string>

namespace au {
namespace dec {
Expand Down
1 change: 1 addition & 0 deletions src/logger_win.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

#include "logger.h"
#include <windows.h>
#include <stdexcept>

using namespace au;

Expand Down