Skip to content

Commit 23ab8e8

Browse files
authored
Merge pull request #172 from DenverM80/win64_cmake
Windows 32 and 64 builds updated to use cmake
2 parents 3cf8ec5 + 9beec8b commit 23ab8e8

File tree

314 files changed

+206
-61144
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

314 files changed

+206
-61144
lines changed

src/CMakeLists.txt

Lines changed: 63 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
if (WIN32)
2-
set(WINDOWS_VS_OUTPUT_DIR ${PROJECT_SOURCE_DIR}/win32/output/bin)
2+
set(WINDOWS_VS_OUTPUT_DIR ${PROJECT_SOURCE_DIR}/win32/output/bin)
33

4-
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${WINDOWS_VS_OUTPUT_DIR})
5-
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${WINDOWS_VS_OUTPUT_DIR})
6-
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${WINDOWS_VS_OUTPUT_DIR})
4+
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${WINDOWS_VS_OUTPUT_DIR})
5+
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${WINDOWS_VS_OUTPUT_DIR})
6+
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${WINDOWS_VS_OUTPUT_DIR})
77

8-
foreach( OUTPUTCONFIG ${CMAKE_CONFIGURATION_TYPES} )
9-
string( TOUPPER ${OUTPUTCONFIG} OUTPUTCONFIG )
10-
set( CMAKE_RUNTIME_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${WINDOWS_VS_OUTPUT_DIR} )
11-
set( CMAKE_LIBRARY_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${WINDOWS_VS_OUTPUT_DIR} )
12-
set( CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${WINDOWS_VS_OUTPUT_DIR} )
13-
endforeach( OUTPUTCONFIG CMAKE_CONFIGURATION_TYPES )
8+
foreach( OUTPUTCONFIG ${CMAKE_CONFIGURATION_TYPES} )
9+
string( TOUPPER ${OUTPUTCONFIG} OUTPUTCONFIG )
10+
set( CMAKE_RUNTIME_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${WINDOWS_VS_OUTPUT_DIR} )
11+
set( CMAKE_LIBRARY_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${WINDOWS_VS_OUTPUT_DIR} )
12+
set( CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${WINDOWS_VS_OUTPUT_DIR} )
13+
endforeach( OUTPUTCONFIG CMAKE_CONFIGURATION_TYPES )
1414
endif(WIN32)
1515

1616
add_library(ds3 SHARED
@@ -25,57 +25,64 @@ add_library(ds3 SHARED
2525

2626
if (WIN32)
2727

28-
add_definitions(-DLIBRARY_EXPORTS -DCURL_STATICLIB -Dinline=__inline)
29-
set_property(TARGET ds3 PROPERTY _CRT_SECURE_NO_WARNINGS)
30-
SET_SOURCE_FILES_PROPERTIES(ds3.c PROPERTIES LANGUAGE CXX)
28+
add_definitions(-DLIBRARY_EXPORTS -DCURL_STATICLIB -Dinline=__inline)
29+
set_property(TARGET ds3 PROPERTY _CRT_SECURE_NO_WARNINGS)
30+
set_source_files_properties(ds3.c PROPERTIES LANGUAGE CXX)
3131

32-
include_directories(
33-
../win32/deps/install/include
34-
../win32/deps/install/include/glib-2.0
35-
../win32/deps/install/lib/glib-2.0/include
36-
../win32/compatibility_includes)
37-
target_link_libraries(ds3
38-
../win32/deps/install/lib/libcurl_a
39-
../win32/deps/install/lib/zlib_a
40-
../win32/deps/install/lib/libxml2_a
41-
../win32/deps/install/lib/glib-2.0
42-
Ws2_32)
32+
file(TO_NATIVE_PATH "${PROJECT_SOURCE_DIR}/win32" WINDOWS_DIR)
33+
file(TO_NATIVE_PATH "${WINDOWS_DIR}/deps/install" WINDOWS_INSTALL_DIR)
34+
file(TO_NATIVE_PATH "${WINDOWS_INSTALL_DIR}/lib" WINDOWS_INSTALL_LIB_DIR)
35+
file(TO_NATIVE_PATH "${WINDOWS_INSTALL_DIR}/include" WINDOWS_INSTALL_INCLUDE_DIR)
4336

44-
file(TO_NATIVE_PATH ${WINDOWS_VS_OUTPUT_DIR}/ds3.dll DLL_LOCATION)
45-
file(TO_NATIVE_PATH ${PROJECT_SOURCE_DIR}/test/bin UNIT_TEST_DIR)
46-
ADD_CUSTOM_COMMAND(TARGET ds3 POST_BUILD
47-
COMMAND copy
48-
${DLL_LOCATION} ${UNIT_TEST_DIR})
37+
include_directories(
38+
${WINDOWS_INSTALL_INCLUDE_DIR}
39+
${WINDOWS_INSTALL_INCLUDE_DIR}/glib-2.0
40+
${WINDOWS_INSTALL_INCLUDE_DIR}/glib-2.0/glib
41+
${WINDOWS_INSTALL_LIB_DIR}/glib-2.0/include
42+
${WINDOWS_DIR}/compatibility_includes)
43+
44+
target_link_libraries(ds3
45+
${WINDOWS_INSTALL_LIB_DIR}/libcurl_a.lib
46+
${WINDOWS_INSTALL_LIB_DIR}/zlib_a.lib
47+
${WINDOWS_INSTALL_LIB_DIR}/libxml2_a.lib
48+
${WINDOWS_INSTALL_LIB_DIR}/glib-2.0.lib
49+
Ws2_32)
50+
51+
file(TO_NATIVE_PATH "${WINDOWS_VS_OUTPUT_DIR}/ds3.dll" DLL_LOCATION)
52+
file(TO_NATIVE_PATH "${PROJECT_SOURCE_DIR}/test/bin" UNIT_TEST_DIR)
53+
add_custom_command(TARGET ds3 POST_BUILD
54+
COMMAND copy
55+
${DLL_LOCATION} ${UNIT_TEST_DIR})
4956
else(WIN32)
50-
find_package(LibXml2 2.9 REQUIRED)
51-
find_package(CURL 7.31 REQUIRED)
52-
find_package(GLIB2 2.34 REQUIRED)
57+
find_package(LibXml2 2.9 REQUIRED)
58+
find_package(CURL 7.31 REQUIRED)
59+
find_package(GLIB2 2.34 REQUIRED)
5360

54-
if (LIBXML2_FOUND)
55-
include_directories(${LIBXML2_INCLUDE_DIR})
56-
target_link_libraries (ds3 ${LIBXML2_LIBRARIES})
57-
endif (LIBXML2_FOUND)
61+
if (LIBXML2_FOUND)
62+
include_directories(${LIBXML2_INCLUDE_DIR})
63+
target_link_libraries (ds3 ${LIBXML2_LIBRARIES})
64+
endif (LIBXML2_FOUND)
5865

59-
if (CURL_FOUND)
60-
include_directories(${CURL_INCLUDE_DIRS})
61-
target_link_libraries (ds3 ${CURL_LIBRARIES})
62-
endif (CURL_FOUND)
66+
if (CURL_FOUND)
67+
include_directories(${CURL_INCLUDE_DIRS})
68+
target_link_libraries (ds3 ${CURL_LIBRARIES})
69+
endif (CURL_FOUND)
6370

64-
if (GLIB2_FOUND)
65-
include_directories(${GLIB2_INCLUDE_DIRS})
66-
target_link_libraries (ds3 ${GLIB2_LIBRARIES})
67-
endif(GLIB2_FOUND)
71+
if (GLIB2_FOUND)
72+
include_directories(${GLIB2_INCLUDE_DIRS})
73+
target_link_libraries (ds3 ${GLIB2_LIBRARIES})
74+
endif(GLIB2_FOUND)
6875

69-
install(FILES
70-
"ds3.h"
71-
"ds3_connection.h"
72-
"ds3_net.h"
73-
"ds3_request.h"
74-
"ds3_string.h"
75-
"ds3_string_multimap.h"
76-
"ds3_string_multimap_impl.h"
77-
"ds3_utils.h"
78-
DESTINATION
79-
"/usr/local/include")
80-
install(TARGETS ds3 DESTINATION lib)
76+
install(FILES
77+
"ds3.h"
78+
"ds3_connection.h"
79+
"ds3_net.h"
80+
"ds3_request.h"
81+
"ds3_string.h"
82+
"ds3_string_multimap.h"
83+
"ds3_string_multimap_impl.h"
84+
"ds3_utils.h"
85+
DESTINATION
86+
"/usr/local/include")
87+
install(TARGETS ds3 DESTINATION lib)
8188
endif(WIN32)

win32/Makefile.vc

Lines changed: 0 additions & 48 deletions
This file was deleted.

win32/README.md

Lines changed: 24 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,42 @@ Overview
22
--------
33

44
This directory contains all of the files needed to build under Windows.
5-
Currently we build using cmake and MSVC 2015 and above.
5+
Currently we build using CMake and MSVC 2015 and above.
66

77
Prerequisites
88
-------------
99

1010
1. Boost C++ library installed to a default location on the machine
11+
2. PowerShell 3+
12+
3. If you don't already have 7zip, it will be downloaded and placed in the Windows Temp directory to untar glib.
1113

14+
Dependencies
15+
------------
16+
17+
The SDK depends upon several open source libraries.
18+
19+
To acquire the dependencies, follow the following procedure:
20+
21+
1. Ensure the built dependency directory at `/win32/deps/install` is empty.
22+
2. Download and extract the dependency library packages. Depending on whether you want 32 or 64 bit libs, run one of the following:
23+
* `\win32\deps\build\download_and_unzip.bat`
24+
* `\win32\deps\build\download_and_unzip_64.bat`
25+
* You can also manually download the URLs and extract using whatever utility you like. Note that the glib package must be extracted to `/win32/deps/build/prebuilt`.
26+
3. The Windows batch file `/win32/deps/install(_64).bat` compiles and installs the dependencies into the `/win32/deps/install` directory. It executes the Visual Studio 14 2015 Command Prompt environment script, so if you're using a different version you'll have to modify the Visual Studio install path inside of `install(_64).bat`.
1227

13-
Basic Build
28+
29+
Build
1430
-----------
1531

1632
To build the client library
1733

1834

1935
1. Open a new Visual Studio Command Prompt.
20-
2. Navigate to the ds3_c_sdk directory.
21-
3. Run the following command: `cmake -G "Visual Studio 14 2015"`
22-
4. Either open the resulting 'libds3.sln' in Visual Studio and build it from
23-
there, or run the command 'msbuild libds3.sln' from the command prompt.
36+
2. Navigate to the ds3_c_sdk\win32 directory.
37+
3. Run `package(_64).bat`, which will use CMake to create a Visual Studio 14 2015 solution, and then compile from the command line using msbuild, and compress all requiredSDK dependencies into a `ds3_win(32 or 64).zip`
38+
3. Run the following command: `cmake .. -G "Visual Studio 14 2015 {Win64}"`
39+
4. Either open the resulting `libds3.sln` in Visual Studio and build it from
40+
there, or run the command `msbuild libds3.sln` from the command prompt.
2441
This should build the libds3 library, which is placed in the directory '<root of repo>/win32/output/bin'
2542

2643

@@ -29,31 +46,10 @@ Unit Tests
2946

3047
1. Open a new Visual Studio Command Prompt.
3148
2. Navigate to the ds3_c_sdk/test directory.
32-
3. Run the following command: `cmake -G "Visual Studio 14 2015"`
49+
3. Run the following command: `cmake ..\.. -G "Visual Studio 14 2015 {Win64}"`
3350
4. Either open the resulting 'libds3_tests.sln' in Visual Studio and build it
3451
from there, or run the command 'msbuild libds3_tests.sln' from the command
3552
prompt. This should build the libds3 library, which is placed in the directory
3653
'<root of repo>/tests/bin'
3754

3855

39-
Dependencies
40-
------------
41-
42-
The SDK depends upon several open source libraries. For convenience we
43-
redistribute these dependencies in the `/win32/deps/install` directory,
44-
except for the Boost library headers.
45-
46-
To re-build the dependencies, follow the following procedure:
47-
48-
1. Delete the built dependency directory at `/win32/deps/install`.
49-
2. Download and extract the dependency library packages.
50-
* The Unix shell script at `/win32/deps/build/download_and_unzip.sh` can do
51-
this for you, but you don't strictly need to use it. You can also manually
52-
download the URLs and extract using whatever utility you like. Note that
53-
the glib package must be extracted to `/win32/deps/build/prebuilt`.
54-
3. The Windows batch file `/win32/deps/install.bat` compiles and installs the
55-
dependencies into the `/win32/deps/install` directory. It executes the
56-
Visual Studio 2012 Command Prompt environment script, so if you're using a
57-
different version you'll have to modify the Visual Studio install path inside
58-
of `install.bat`.
59-
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
@echo off
2+
powershell -ExecutionPolicy RemoteSigned -File download_and_unzip.ps1
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# download 32bit library dependencies and put into expected layout for install.
2+
3+
. "$PSScriptRoot\util.ps1" # provides Unzip and Untar
4+
5+
(new-object System.Net.WebClient).DownloadFile(
6+
'http://curl.haxx.se/download/curl-7.37.0.zip',
7+
'curl-7.37.0.zip')
8+
Unzip curl-7.37.0.zip .
9+
Remove-Item curl-7.37.0.zip
10+
11+
(new-object System.Net.WebClient).DownloadFile(
12+
'http://zlib.net/zlib128.zip',
13+
'zlib128.zip')
14+
Unzip zlib128.zip .
15+
Remove-Item zlib128.zip
16+
17+
(new-object System.Net.WebClient).DownloadFile(
18+
'ftp://xmlsoft.org/libxml2/libxml2-2.9.4.tar.gz',
19+
'libxml2-2.9.4.tar.gz')
20+
Untar libxml2-2.9.4.tar.gz .
21+
Remove-Item libxml2-2.9.4.tar.gz
22+
23+
(new-object System.Net.WebClient).DownloadFile(
24+
'http://win32builder.gnome.org/gtk+-bundle_3.6.4-20130921_win32.zip',
25+
'gtk+-bundle_3.6.4-20130921_win32.zip')
26+
Unzip gtk+-bundle_3.6.4-20130921_win32.zip prebuilt
27+
Remove-Item gtk+-bundle_3.6.4-20130921_win32.zip
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
@echo off
2+
powershell -ExecutionPolicy RemoteSigned -File download_and_unzip_64.ps1
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# download 64bit library dependencies and put into expected layout for install.
2+
3+
. "$PSScriptRoot\util.ps1" # provides Unzip and Untar
4+
5+
(new-object System.Net.WebClient).DownloadFile('http://curl.haxx.se/download/curl-7.37.0.zip','curl-7.37.0.zip')
6+
Unzip curl-7.37.0.zip .
7+
Remove-Item curl-7.37.0.zip
8+
9+
(new-object System.Net.WebClient).DownloadFile('http://zlib.net/zlib128.zip','zlib128.zip')
10+
Unzip zlib128.zip .
11+
Remove-Item zlib128.zip
12+
13+
(new-object System.Net.WebClient).DownloadFile('ftp://xmlsoft.org/libxml2/libxml2-2.9.4.tar.gz','libxml2-2.9.4.tar.gz')
14+
Untar libxml2-2.9.4.tar.gz .
15+
Remove-Item libxml2-2.9.4.tar.gz
16+
17+
(new-object System.Net.WebClient).DownloadFile('http://win32builder.gnome.org/gtk+-bundle_3.6.4-20131201_win64.zip','gtk+-bundle_3.6.4-20131201_win64.zip')
18+
Unzip gtk+-bundle_3.6.4-20131201_win64.zip prebuilt
19+
Remove-Item gtk+-bundle_3.6.4-20131201_win64.zip

win32/deps/build/util.ps1

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
Add-Type -AssemblyName System.IO.Compression.FileSystem
2+
function Unzip
3+
{
4+
param(
5+
[Parameter(Mandatory=$true)][string]$zipfile,
6+
[Parameter(Mandatory=$true)][string]$outpath
7+
)
8+
9+
[System.IO.Compression.ZipFile]::ExtractToDirectory($zipfile, $outpath)
10+
}
11+
12+
function Untar() {
13+
param(
14+
[Parameter(Mandatory=$true)][string]$archive,
15+
[Parameter(Mandatory=$true)][string]$outpath
16+
)
17+
18+
$7z_path = "$env:TEMP\7z"
19+
if (!(test-path $7z_path) -or !(test-path "$7z_path\7za.exe")) {
20+
if (!(test-path $7z_path)) { md $7z_path | out-null }
21+
push-location $7z_path
22+
try {
23+
write-host "Downloading 7zip" -foregroundcolor cyan
24+
25+
$7zip_dl = "http://www.7-zip.org/a/7za920.zip"
26+
(new-object System.Net.WebClient).DownloadFile("$7zip_dl", "$7z_path\7za.zip")
27+
28+
write-host "done." -foregroundcolor green
29+
30+
Unzip "$7z_path\7za.zip" "$7z_path"
31+
del "$7z_path\7za.zip"
32+
}
33+
finally { pop-location }
34+
}
35+
write-host $7za_path
36+
$7za_exe = "$7z_path" + '\7za.exe'
37+
write-host $7za_exe
38+
39+
if ($archive.endswith('.tar.gz') -or $archive.endswith('.tgz')) {
40+
$x = "cmd.exe"
41+
# Properly handle paths and archives with spaces in names
42+
$y = "/C `"^`"$7za_exe^`" e ^`"$archive^`" -so | ^`"$7za_exe^`" x -aoa -si -ttar -o^`"$outpath^`""
43+
& $x $y | findstr /v /b /c:"Extracting " # suppress noisy per file msg
44+
} else {
45+
& "$7za_exe" x $archive -y -o"$outpath" | findstr /v /b /c:"Extracting " # suppress noisy per file msg
46+
}
47+
}
-1.42 MB
Binary file not shown.
-999 KB
Binary file not shown.

0 commit comments

Comments
 (0)