Skip to content

Instantly share code, notes, and snippets.

@abergmeier
Last active March 22, 2016 16:26
Show Gist options
  • Save abergmeier/3793621e644c222d03ac to your computer and use it in GitHub Desktop.
Save abergmeier/3793621e644c222d03ac to your computer and use it in GitHub Desktop.
## Bootstrapping
set VISUAL_STUDIO_VER=14
set CMAKE_GENERATOR="Visual Studio %VISUAL_STUDIO_VER% 2015 Win64"
set MSBUILD_VERSION=%VISUAL_STUDIO_VER%.0
rem Find msbuild path
for /f "usebackq skip=2 tokens=3*" %%A in (`reg.exe query "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSBuild\ToolsVersions\%MSBUILD_VERSION%" /v "MSBuildToolsPath" `) do (
set MSBUILD_PATH=%%A %%B
)
mkdir Compiled\3rdparty
@cd Compiled\3rdparty
%CMAKE% -G %CMAKE_GENERATOR% ../../3rdparty
"%MSBUILD_PATH%Msbuild.exe" 3rdparty.sln /property:Configuration=RelWithDebInfo
cd ..\..
## Enforce finding local libraries
set( OLD_CMAKE_PREFIX_PATH "${CMAKE_PREFIX_PATH}" )
set( CMAKE_PREFIX_PATH "${CMAKE_CURRENT_LIST_DIR}/Compiled/3rdparty/curl/x64_Release" )
find_package( CURL REQUIRED )
set( CMAKE_PREFIX_PATH "${OLD_CMAKE_PREFIX_PATH}" )
## WIN32 instead of MSVC for bootstrapping
project( 3rdparty )
cmake_minimum_required( VERSION 3.2 )
include( ExternalProject )
if( WIN32 )
ExternalProject_Add( boost_libs
PREFIX boost
SOURCE_DIR boost/lib
URL http://foo.com/boost-1.60_lib64-msvc-14.0.zip
URL_MD5 7370b042e0e915d34f2b40427831a563
UPDATE_COMMAND ""
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
BUILD_IN_SOURCE ON
INSTALL_COMMAND ""
)
add_custom_target( dependencies ALL
DEPENDS boost_libs
)
elseif( APPLE )
elseif( UNIX )
ExternalProject_Add( boost_libs
PREFIX boost
URL http://foo.com/boost_1_60_0.tar.bz2
URL_MD5 65a840e1a0b13a558ff19eeb2c4f0cbe
UPDATE_COMMAND ""
CONFIGURE_COMMAND "${CMAKE_CURRENT_BINARY_DIR}/boost/src/boost_libs/bootstrap.sh" "--prefix=${CMAKE_CURRENT_BINARY_DIR}/boost/"
BUILD_COMMAND ./b2 -j 8
BUILD_IN_SOURCE ON
INSTALL_COMMAND ./b2 install
)
else()
message( FATAL_ERROR Unknown platform )
endif()
## Do not introduce LINUX or other crap
## Always have default working
## Use Modules
## Insert version into binaries
set( MY_MAJOR_VERSION 2 )
set( MY_MINOR_VERSION 3 )
set( MY_RELEASE_VERSION 7 )
configure_file( SVersionNo.h.in "${CMAKE_CURRENT_SOURCE_DIR}/VersionNo.h" )
#define MAJOR_VERSION @MY_MAJOR_VERSION@
## Protobuf
protobuf_generate_cpp( SHARED_PROTO_SRC SHARED_PROTO_HDR
testme.proto
)
protobuf_generate_python( PROTO_PY
testme.proto
)
## Dual install
function( my_deploy name destination )
install(
FILES
${ARGN}
DESTINATION "${destination}"
)
set( commands )
foreach( file ${ARGN} )
get_filename_component( filename "${file}" NAME )
list( APPEND commands COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${file}" "$<TARGET_FILE_DIR:mytarget>/${destination}/${filename}" )
endforeach()
add_custom_target( MyTargetDeploy${name}
ALL
COMMAND "${CMAKE_COMMAND}" -E make_directory "$<TARGET_FILE_DIR:mytarget>/${destination}"
${commands}
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
)
endfunction()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment