Commit 86dfa28f authored by Jørgen Lind's avatar Jørgen Lind
Browse files

Fixup building of shared library on windows

parent ee05ec1b
function(copyDllForTarget target)
if (WIN32)
add_custom_command(TARGET ${target}
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${AWS_DLLS} $<TARGET_FILE:openvds> $<TARGET_FILE_DIR:${target}>)
endif()
endfunction()
......@@ -6,7 +6,7 @@ set_property(GLOBAL PROPERTY USE_FOLDERS ON)
find_package(Threads)
if (UNIX)
add_definitions(-Wreturn-type -pthread)
add_definitions(-Wreturn-type)
endif()
set(AWS_VERSION 1.7.90)
......@@ -29,12 +29,13 @@ list(APPEND AWS_LIBS "${AWS_INSTALL}/lib/libaws-cpp-sdk-s3.so")
list(APPEND AWS_LIBS "crypto")
list(APPEND AWS_LIBS "curl")
endif()
add_definitions(-DUSE_IMPORT_EXPORT)
add_definitions(-DUSE_IMPORT_EXPORT)
include_directories(${CMAKE_CURRENT_BINARY_DIR})
if (NOT (EXISTS ${AWS_SOURCE_DIR}))
include(CMake/FetchContentLocal.cmake)
set(FETCHCONTENT_QUIET OFF)
FetchContent_Declare( aws-cpp-sdk-download
URL https://github.com/aws/aws-sdk-cpp/archive/${AWS_VERSION}.zip
URL_MD5 d2b923b1ea11e780365cbec0fc627b7f
......@@ -52,6 +53,7 @@ ExternalProject_Add(aws-cpp-sdk
BUILD_BYPRODUCTS ${AWS_LIBS}
)
include (CMake/CopyDllForTarget.cmake)
add_subdirectory(src)
enable_testing()
......
......@@ -4,14 +4,15 @@ set(SOURCE_FILES
Linux_File.cpp
Win_File.cpp
S3_Downloader.cpp
open-vds.cpp)
OpenVDS.cpp)
set (PRIVATE_HEADER_FILES
File.h
S3_Downloader.h)
set (EXPORTED_HEADER_FILES
open-vds/open-vds.h)
OpenVDS/OpenVDS.h
OpenVDS/openvds_export.h)
add_library(openvds SHARED
${PRIVATE_HEADER_FILES}
......@@ -19,8 +20,9 @@ add_library(openvds SHARED
${SOURCE_FILES}
)
add_definitions(-Dopenvds_EXPORTS)
add_dependencies(openvds aws-cpp-sdk)
target_include_directories(openvds PRIVATE "${AWS_INCLUDE_PATH}")
target_include_directories(openvds PRIVATE "${AWS_INCLUDE_PATH}" "${CMAKE_CURRENT_SOURCE_DIR}")
target_link_libraries(openvds PUBLIC Threads::Threads ${AWS_LIBS})
if (WIN32)
......@@ -30,7 +32,7 @@ elseif (UNIX)
endif()
if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX ${PROJECT_SOURCE_DIR}/Dist/open-vds CACHE STRING "" FORCE)
set(CMAKE_INSTALL_PREFIX ${PROJECT_SOURCE_DIR}/Dist/OpenVDS CACHE STRING "" FORCE)
endif(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set_target_properties(openvds
......@@ -49,14 +51,14 @@ endif()
install(TARGETS openvds
ARCHIVE
DESTINATION lib_static${LIB_TOOLSET_DIR}
DESTINATION lib${LIB_TOOLSET_DIR}
LIBRARY
DESTINATION lib${LIB_TOOLSET_DIR}
RUNTIME
DESTINATION bin${LIB_TOOLSET_DIR}
PUBLIC_HEADER
DESTINATION include
DESTINATION include/OpenVDS
PRIVATE_HEADER
DESTINATION include/private
DESTINATION include/OpenVDS/private
)
......@@ -21,6 +21,8 @@
#include <string>
#include <vector>
#include <OpenVDS/openvds_export.h>
namespace OpenVDS
{
......@@ -32,7 +34,7 @@ struct IOError
std::string string;
};
class FileView
class OPENVDS_EXPORT FileView
{
int m_nReferenceCount;
protected:
......@@ -82,7 +84,7 @@ public:
// This class is thread-safe except for the following methods:
// open, close, createFileView
// The user must ensure that these methods are called from a single thread only.
class File
class OPENVDS_EXPORT File
{
public:
......
......@@ -15,6 +15,6 @@
** limitations under the License.
****************************************************************************/
#include "open-vds/open-vds.h"
#include "OpenVDS/OpenVDS.h"
......@@ -15,8 +15,11 @@
** limitations under the License.
****************************************************************************/
#ifndef OPEN_VDS_H
#define OPEN_VDS_H
#ifndef OPENVDS_H
#define OPENVDS_H
#include "openvds_export.h"
#endif //OPEN_VDS_H
OPENVDS_EXPORT void s3_function();
#endif //OPENVDS_H
/****************************************************************************
** Copyright 2019 The Open Group
** Copyright 2019 Bluware, Inc.
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
** http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
****************************************************************************/
#ifndef OPENVDS_EXPORT_H
#define OPENVDS_EXPORT_H
#ifdef OPENVDS_STATIC_DEFINE
# define OPENVDS_EXPORT
# define OPENVDS_NO_EXPORT
#else
# if _WIN32
# ifndef OPENVDS_EXPORT
# ifdef openvds_EXPORTS
/* We are building this library */
# define OPENVDS_EXPORT __declspec(dllexport)
# else
/* We are using this library */
# define OPENVDS_EXPORT __declspec(dllimport)
# endif
# endif
# ifndef OPENVDS_NO_EXPORT
# define OPENVDS_NO_EXPORT
# endif
# else
# ifndef OPENVDS_EXPORT
# ifdef openvds_EXPORTS
/* We are building this library */
# define OPENVDS_EXPORT __attribute__((visibility("default")))
# else
/* We are using this library */
# define OPENVDS_EXPORT __attribute__((visibility("default")))
# endif
# endif
# ifndef OPENVDS_NO_EXPORT
# define OPENVDS_NO_EXPORT __attribute__((visibility("hidden")))
# endif
# endif
#endif
#ifndef OPENVDS_DEPRECATED
# if _WIN32
# define OPENVDS_DEPRECATED __declspec(deprecated)
# else
# define OPENVDS_DEPRECATED __attribute__ ((__deprecated__))
# endif
#endif
#ifndef OPENVDS_DEPRECATED_EXPORT
# define OPENVDS_DEPRECATED_EXPORT OPENVDS_EXPORT OPENVDS_DEPRECATED
#endif
#ifndef OPENVDS_DEPRECATED_NO_EXPORT
# define OPENVDS_DEPRECATED_NO_EXPORT OPENVDS_NO_EXPORT OPENVDS_DEPRECATED
#endif
#if 0 /* DEFINE_NO_DEPRECATED */
# ifndef OPENVDS_NO_DEPRECATED
# define OPENVDS_NO_DEPRECATED
# endif
#endif
#endif /* OPENVDS_EXPORT_H */
......@@ -16,7 +16,7 @@
****************************************************************************/
#include "S3_Downloader.h"
#include "OpenVDS/openvds_export.h"
#include <vector>
#include <aws/core/Aws.h>
......@@ -33,7 +33,7 @@ static std::string convert_aws_string(const Aws::String &str)
return std::string(str.data(), str.size());
}
void s3_function()
OPENVDS_EXPORT void s3_function()
{
Aws::SDKOptions options;
Aws::InitAPI(options);
......
......@@ -16,4 +16,4 @@
****************************************************************************/
void s3_function();
//void s3_function();
add_executable(io-filetest io/filetest.cpp)
target_include_directories(io-filetest PRIVATE ${PROJECT_SOURCE_DIR}/src)
target_link_libraries(io-filetest openvds Threads::Threads)
if (UNIX)
target_link_libraries(io-filetest -pthread)
endif()
add_test(NAME io-filetest COMMAND io-filetest)
add_executable(io_filetest io/filetest.cpp)
target_include_directories(io_filetest PRIVATE ${PROJECT_SOURCE_DIR}/src)
target_link_libraries(io_filetest openvds Threads::Threads)
add_test(NAME io_filetest COMMAND io_filetest)
copyDllForTarget(io_filetest)
add_executable(io-s3test io/s3test.cpp)
target_include_directories(io-s3test PRIVATE ${PROJECT_SOURCE_DIR}/src)
target_link_libraries(io-s3test openvds Threads::Threads)
add_test(NAME io-s3test COMMAND io-s3test)
if (WIN32)
add_custom_command(TARGET io-s3test
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${AWS_DLLS} $<TARGET_FILE_DIR:io-s3test>)
endif()
add_executable(io_s3test io/s3test.cpp)
target_include_directories(io_s3test PRIVATE ${PROJECT_SOURCE_DIR}/src)
target_link_libraries(io_s3test openvds Threads::Threads)
add_test(NAME io_s3test COMMAND io_s3test)
copyDllForTarget(io_s3test)
......@@ -15,13 +15,13 @@
** limitations under the License.
****************************************************************************/
#include "S3_Downloader.h"
#include "OpenVDS/OpenVDS.h"
#include <stdio.h>
int main()
{
fprintf(stderr, "S3 Downloader\n");
//s3_function();
s3_function();
return 0;
}
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment