CMakeLists.txt 5.74 KB
Newer Older
Jørgen Lind's avatar
Jørgen Lind committed
1

Jørgen Lind's avatar
Jørgen Lind committed
2
3
4
5
6
7
8
9
10
if(WIN32)
  list(APPEND CMAKE_MODULE_PATH ${dmsCMakeDir}/modules/version_info_win32)
endif()

set (CMAKE_CXX_STANDARD 14)
set (CMAKE_CXX_STANDARD_REQUIRED ON)

include_directories(${dmsCMakeDir}/src/core)
include_directories(${dmsCMakeDir}/src/lib)
Jørgen Lind's avatar
Jørgen Lind committed
11
include_directories(${dmsCMakeDir}/src/lib/cloud)
Jørgen Lind's avatar
Jørgen Lind committed
12
include_directories(${dmsCMakeDir}/src/lib/cloud/providers)
Jørgen Lind's avatar
Jørgen Lind committed
13
include_directories(${dmsCMakeDir}/src/lib/cloud/providers/gcs-accessor)
Jørgen Lind's avatar
Jørgen Lind committed
14
15
16

# retrieve sources
file(GLOB SRC_CORE ${dmsCMakeDir}/src/core/*.cc)
Jørgen Lind's avatar
Jørgen Lind committed
17
file(GLOB SRC_LIB_PROVIDERS ${dmsCMakeDir}/src/lib/cloud/*.cc ${dmsCMakeDir}/src/lib/cloud/providers/gcs-accessor/*.cc)
Jørgen Lind's avatar
Jørgen Lind committed
18
19
20
21
22
file(GLOB SRC_LIB_HTTP ${dmsCMakeDir}/src/lib/http/*.cc)
file(GLOB SRC_LIB_JSON ${dmsCMakeDir}/src/lib/json/*.cpp)
file(GLOB SRC_LIB_AUTH ${dmsCMakeDir}/src/lib/auth/*.cc)
file(GLOB SRC_LIB_SHARED ${dmsCMakeDir}/src/lib/shared/*.cc)
set(SOURCES ${SRC_CORE} ${SRC_LIB_ACCESSORS} ${SRC_LIB_PROVIDERS} ${SRC_LIB_HTTP} ${SRC_LIB_JSON} ${SRC_LIB_AUTH} ${SRC_LIB_SHARED})
Jørgen Lind's avatar
Jørgen Lind committed
23
24
25
26
27
28
29
30
31
32

if (MSVC)
  set(DISABLE_WARNING_FLAG "/W0 /WX-")
else()
  set(DISABLE_WARNING_FLAG "-w")
endif()

if (NOT DISABLE_AZURE_IOMANAGER)
  add_definitions( -DHAS_AZURE_BLOB_STORAGE_PROVIDER )
  file(GLOB SRC_LIB_PROVIDERS_AZURE ${dmsCMakeDir}/src/lib/cloud/providers/azure/cpprest/*.cc)
Jørgen Lind's avatar
Jørgen Lind committed
33
34
35
  set(SOURCES ${SOURCES} ${SRC_LIB_PROVIDERS_AZURE})
endif()

Jørgen Lind's avatar
Jørgen Lind committed
36
37
38
39
40
41
if (NOT DISABLE_AZURESDKFORCPP_IOMANAGER)
  add_definitions( -DHAS_AZURE_BLOB_STORAGE_PROVIDER_CURL )
  file(GLOB SRC_LIB_PROVIDERS_AZURE_NEW ${dmsCMakeDir}/src/lib/cloud/providers/azure/curl/*.cc)
  set(SOURCES ${SOURCES} ${SRC_LIB_PROVIDERS_AZURE_NEW})
endif()

Jørgen Lind's avatar
Jørgen Lind committed
42
43
44
45
if (NOT DISABLE_AWS_IOMANAGER)
  add_definitions( -DHAS_AWS_S3_STORAGE_PROVIDER )
  file(GLOB SRC_LIB_PROVIDERS_AWS   ${dmsCMakeDir}/src/lib/cloud/providers/aws/*.cc)
  set(SOURCES ${SOURCES} ${SRC_LIB_PROVIDERS_AWS})
Jørgen Lind's avatar
Jørgen Lind committed
46
47
48
49
50
51
  set_source_files_properties(${dmsCMakeDir}/src/lib/cloud/providers/aws/AwsStorage.cc PROPERTIES COMPILE_FLAGS ${DISABLE_WARNING_FLAG})

  add_definitions( -DHAS_IBM_STORAGE_PROVIDER )
  file(GLOB SRC_LIB_PROVIDERS_IBM  ${dmsCMakeDir}/src/lib/cloud/providers/ibm/*.cc)
  set(SOURCES ${SOURCES} ${SRC_LIB_PROVIDERS_IBM})
  set_source_files_properties(${dmsCMakeDir}/src/lib/cloud/providers/ibm/IbmStorage.cc PROPERTIES COMPILE_FLAGS ${DISABLE_WARNING_FLAG})
52
53
54
55
56
57
58

  #to work around Aws::String problem
  #https://github.com/aws/aws-sdk-cpp/blob/266d7682c3d07d41618c41a3521811e1219c1bc7/aws-cpp-sdk-core/include/aws/core/utils/memory/stl/AWSString.h#L21
  if (NOT MSVC)
    set_property(SOURCE ${dmsCMakeDir}/src/lib/cloud/providers/aws/AwsStorage.cc APPEND_STRING PROPERTY COMPILE_FLAGS " -fvisibility=default")
    set_property(SOURCE ${dmsCMakeDir}/src/lib/cloud/providers/ibm/IbmStorage.cc APPEND_STRING PROPERTY COMPILE_FLAGS " -fvisibility=default")
  endif()
Jørgen Lind's avatar
Jørgen Lind committed
59
60
endif()

Jørgen Lind's avatar
Jørgen Lind committed
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
# set major library versions
if(NOT DEFINED LIB_VERSION_MAJOR)
  set(LIB_VERSION_MAJOR 0)
endif()

# set minor library versions
if(NOT DEFINED LIB_VERSION_MINOR)
  set(LIB_VERSION_MINOR 0)
endif()

# set patch library versions
if(NOT DEFINED LIB_VERSION_PATCH)
  if(DEFINED LIBVERSION) # backward compatibility (old naming convention for patch)
    set(LIB_VERSION_PATCH ${LIBVERSION})
  elseif(DEFINED SDAPI_WIN_VERSION) # backward compatibility (old naming convention for patch)
    set(LIB_VERSION_PATCH ${SDAPI_WIN_VERSION})
  else()
    set(LIB_VERSION_PATCH 0)
  endif()
endif()

# set the versioninfo file for win32
if(WIN32)
  include(generate_product_version)
  generate_product_version(
    VersionFilesOutputVariable
    NAME "sdapi"
    VERSION_MAJOR ${LIB_VERSION_MAJOR}
    VERSION_MINOR ${LIB_VERSION_MINOR}
    VERSION_PATCH ${LIB_VERSION_PATCH}
    COMPANY_NAME "Schlumberger"
  )
endif()


add_library (sdapi_objects OBJECT ${SOURCES} ${VersionFilesOutputVariable})

get_property(link_3rdparty_release GLOBAL PROPERTY OPENVDS_LINK_LIBRARIES_RELEASE)
get_property(link_3rdparty_debug   GLOBAL PROPERTY OPENVDS_LINK_LIBRARIES_DEBUG)
get_property(runtime_3rdparty_release GLOBAL PROPERTY OPENVDS_RUNTIME_LIBS_RELEASE)
get_property(runtime_3rdparty_debug   GLOBAL PROPERTY OPENVDS_RUNTIME_LIBS_DEBUG)
get_property(include_3rdparty      GLOBAL PROPERTY OPENVDS_INCLUDE_LIBRARIES)
get_property(dependency_targets_3rdparty      GLOBAL PROPERTY OPENVDS_DEPENDENCY_TARGETS)

addSystemHeadersToTarget(sdapi_objects "${include_3rdparty}")

if (UNIX)
  find_package(Boost REQUIRED COMPONENTS system date_time regex)
Jørgen Lind's avatar
Jørgen Lind committed
109
  target_link_libraries(sdapi_objects PRIVATE Boost::system)
Jørgen Lind's avatar
Jørgen Lind committed
110
111
112
endif()

add_library(sdapi SHARED $<TARGET_OBJECTS:sdapi_objects>)
Jørgen Lind's avatar
Jørgen Lind committed
113
114
115
116
117

foreach(DEP ${dependency_targets_3rdparty})
  add_dependencies(sdapi_objects ${DEP})
endforeach()

Jørgen Lind's avatar
Jørgen Lind committed
118
target_link_libraries(sdapi PUBLIC sdapi_objects)
Jørgen Lind's avatar
Jørgen Lind committed
119
120
121
122
123
124
foreach(item ${link_3rdparty_debug})
    target_link_libraries(sdapi PRIVATE debug ${item})
endforeach()
foreach(item ${link_3rdparty_release})
    target_link_libraries(sdapi PRIVATE optimized ${item})
endforeach()
Jørgen Lind's avatar
Jørgen Lind committed
125

Jørgen Lind's avatar
Jørgen Lind committed
126
127
128
setLTOForTarget(sdapi_objects)
setLTOForTarget(sdapi)

Jørgen Lind's avatar
Jørgen Lind committed
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
if (WIN32)
  if(DEFINED LIB_VERSION_ON_NAME)
    set_target_properties(sdapi PROPERTIES
      OUTPUT_NAME "sdapi_${LIB_VERSION_MAJOR}.${LIB_VERSION_MINOR}.${LIB_VERSION_PATCH}"
      POSITION_INDEPENDENT_CODE ON)
  else()
    set_target_properties(sdapi PROPERTIES
      OUTPUT_NAME "sdapi"
      POSITION_INDEPENDENT_CODE ON)      
  endif()
else()
  set_target_properties(sdapi PROPERTIES
    SOVERSION ${LIB_VERSION_MAJOR}.${LIB_VERSION_MINOR}
    VERSION ${LIB_VERSION_MAJOR}.${LIB_VERSION_MINOR}.${LIB_VERSION_PATCH}
    CXX_VISIBILITY_PRESET hidden
    OUTPUT_NAME "sdapi"
    POSITION_INDEPENDENT_CODE ON)

endif()

install(TARGETS sdapi sdapi_objects
  EXPORT sdapi-export
  ARCHIVE
    DESTINATION ${CMAKE_INSTALL_LIBDIR}${LIB_TOOLSET_DIR}
  LIBRARY
    DESTINATION ${CMAKE_INSTALL_LIBDIR}${LIB_TOOLSET_DIR}
  RUNTIME
    DESTINATION ${CMAKE_INSTALL_BINDIR}${LIB_TOOLSET_DIR}
  FRAMEWORK
    DESTINATION framework
)