Skip to content

Commit

Permalink
fixing cmake file, adding cmake settings json
Browse files Browse the repository at this point in the history
add build helper script

extend windows build script to use vcpkg

Adding check for invalid windows options
  • Loading branch information
peterychang committed Apr 17, 2019
1 parent 6c06548 commit 9d6fc4e
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 11 deletions.
15 changes: 8 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build." FORCE)
endif()

project(vowpal_wabbit C CXX)
set(CMAKE_CXX_STANDARD 11)

# VW targets Windows 8.1 SDK
if(WIN32)
set(CMAKE_SYSTEM_VERSION 8.1 CACHE TYPE INTERNAL FORCE)
endif()

project(vowpal_wabbit C CXX)
set(CMAKE_CXX_STANDARD 11)

# Read version into variable
file(READ version.txt PACKAGE_VERSION)
string(STRIP ${PACKAGE_VERSION} PACKAGE_VERSION)
Expand All @@ -40,6 +40,10 @@ option(LTO "Enable Link Time optimization (Requires Release build, only works wi

string(TOUPPER "${CMAKE_BUILD_TYPE}" CONFIG)

if(WIN32 AND (PROFILE OR VALGRIND_PROFILE OR GCOV OR STATIC_LINK_VW OR BUILD_JAVA OR BUILD_PYTHON OR LTO))
message(FATAL_ERROR "Unsupported option enabled on Win32 build")
endif()

# Add -ffast-math for speed, remove for testability.
set(linux_release_config -O3 -fno-strict-aliasing -msse2 -mfpmath=sse)
set(linux_debug_config -g -O0)
Expand Down Expand Up @@ -79,10 +83,6 @@ if(GCOV)
set(linux_flags ${linux_flags} -g -O0 -fprofile-arcs -ftest-coverage -fno-strict-aliasing -pg)
endif()

set(windows_release_config /GL /O2 /Gy /Oi /Ob2 /Ot /Oy /GT /MD)
set(windows_debug_config /INCREMENTAL /Od /Zi /analyze-)
set(windows_flags $<$<CONFIG:DEBUG>:${windows_debug_config}> $<$<CONFIG:RELEASE>:${windows_release_config}>)

# TODO move to consuming vcpkg of this dependency
add_library(rapidjson INTERFACE)
target_include_directories(rapidjson INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/rapidjson/include)
Expand All @@ -98,6 +98,7 @@ if(STATIC_LINK_VW)
SET(BUILD_SHARED_LIBS OFF)
else()
set(Boost_USE_STATIC_LIBS OFF)
add_definitions( -DBOOST_ALL_DYN_LINK )
endif()

set(Boost_USE_MULTITHREADED ON)
Expand Down
30 changes: 30 additions & 0 deletions CMakeSettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"configurations": [
{
"name": "x64-Debug",
"generator": "Visual Studio 14 2015 Win64",
"configurationType": "Debug",
"inheritEnvironments": [
"msvc_x64_x64"
],
"buildRoot": "${env.USERPROFILE}\\CMakeBuilds\\${workspaceHash}\\build\\${name}",
"installRoot": "${env.USERPROFILE}\\CMakeBuilds\\${workspaceHash}\\install\\${name}",
"cmakeCommandArgs": "",
"buildCommandArgs": "/INCREMENTAL /Od /Zi /analyze-",
"ctestCommandArgs": ""
},
{
"name": "x64-Release",
"generator": "Visual Studio 14 2015 Win64",
"configurationType": "RelWithDebInfo",
"inheritEnvironments": [
"msvc_x64_x64"
],
"buildRoot": "${env.USERPROFILE}\\CMakeBuilds\\${workspaceHash}\\build\\${name}",
"installRoot": "${env.USERPROFILE}\\CMakeBuilds\\${workspaceHash}\\install\\${name}",
"cmakeCommandArgs": "",
"buildCommandArgs": "/GL /O2 /Gy /Oi /Ob2 /Ot /Oy /GT /MD",
"ctestCommandArgs": ""
}
]
}
17 changes: 17 additions & 0 deletions build-windows.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
@echo off

IF %1.==. GOTO USAGE

pushd %1
set VCPKG_PATH=%CD%
popd

cmake %~dp0 -G "Visual Studio 14 2015 Win64" -DCMAKE_TOOLCHAIN_FILE=%VCPKG_PATH%\scripts\buildsystems\vcpkg.cmake
msbuild vowpal_wabbit.sln /p:Configuration=Release
GOTO FINISH

:USAGE
ECHO Usage: build_windows.sh [vcpkg_rootdir]
GOTO FINISH

:FINISH
5 changes: 1 addition & 4 deletions vowpalwabbit/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ target_include_directories(allreduce PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
# Winsock32 should be available on Windows
if(WIN32)
target_link_libraries(allreduce PUBLIC wsock32 ws2_32)
target_compile_options(allreduce PUBLIC ${windows_flags})
else()
target_compile_options(allreduce PUBLIC ${linux_flags})
endif()
Expand Down Expand Up @@ -81,8 +80,6 @@ endif()
if(WIN32)
target_compile_definitions(vw PUBLIC __SSE2__)
target_compile_options(vw PUBLIC /MP)

target_compile_options(vw PUBLIC ${windows_flags})
else()
target_compile_options(vw PUBLIC ${linux_flags})
endif()
Expand Down Expand Up @@ -139,7 +136,7 @@ endif()

# This is used by Travis to not build vw_c_wrapper, this required <codecvt> which became available in GCC 5.1
if(NOT DEFINED DO_NOT_BUILD_VW_C_WRAPPER)
add_library(vw_c_wrapper vwdll.cpp)
add_library(vw_c_wrapper SHARED vwdll.cpp)
target_compile_definitions(vw_c_wrapper PUBLIC VWDLL_EXPORTS _CRT_SECURE_NO_WARNINGS _CRT_NONSTDC_NO_DEPRECATE ZLIB_WINAPI)
target_link_libraries(vw_c_wrapper PUBLIC vw)

Expand Down

0 comments on commit 9d6fc4e

Please sign in to comment.