Skip to content

Instantly share code, notes, and snippets.

@MikaelSmith
Last active August 29, 2015 14:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MikaelSmith/8084e571664465ed68df to your computer and use it in GitHub Desktop.
Save MikaelSmith/8084e571664465ed68df to your computer and use it in GitHub Desktop.
CFacter SuperProject
cmake_minimum_required(VERSION 2.8.12)
project(CFACTER-BUILD)
set(BOOST_VERSION 1.56.0)
set(YAMLCPP_VERSION 0.5.1)
set(OPENSSL_VERSION 1.0.1i)
if (NOT CMAKE_BUILD_TYPE)
message(STATUS "Defaulting to a release build.")
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel." FORCE)
endif()
# This project uses ExternalProject to incorporate all libraries used for compilation of the cfacter project.
include (ExternalProject)
if (NOT USE_INSTALL)
# Download, build, and stage boost; set BOOST_ROOT and BOOST_INCLUDEDIR
if (WIN32)
set(Boost_Bootstrap_Command bootstrap.bat)
set(Boost_b2_Command b2.exe)
else()
set(Boost_Bootstrap_Command ./bootstrap.sh)
set(Boost_b2_Command ./b2)
endif()
if (${CMAKE_BUILD_TYPE} STREQUAL "Debug")
set(Boost_Variant debug)
else()
set(Boost_Variant release)
endif()
if (MINGW)
set(Boost_b2_Command "${Boost_b2_Command} mingw")
endif()
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
set(Boost_Toolset toolset=gcc)
else()
set(Boost_Toolset "")
endif()
string(REPLACE "." "_" BOOST_VERSION_ ${BOOST_VERSION})
ExternalProject_Add(
boost
URL http://downloads.sourceforge.net/project/boost/boost/${BOOST_VERSION}/boost_${BOOST_VERSION_}.tar.gz
URL_HASH SHA1=1639723c6bdff873cdb6d747f8f8c9d9f066434d
BUILD_IN_SOURCE 1
UPDATE_COMMAND ""
PATCH_COMMAND ""
CONFIGURE_COMMAND ${Boost_Bootstrap_Command}
BUILD_COMMAND ${Boost_b2_Command} install
${Boost_Toolset}
threading=multi
link=static
runtime-link=shared
variant=${Boost_Variant}
--prefix=${CMAKE_BINARY_DIR}/INSTALL
--libdir=${CMAKE_BINARY_DIR}/INSTALL/lib
--disable-icu
--with-program_options
--with-system
--with-filesystem
--with-date_time
--with-thread
--with-regex
--with-log
INSTALL_COMMAND ""
INSTALL_DIR ${CMAKE_BINARY_DIR}/INSTALL)
set(BOOST_ROOT ${CMAKE_BINARY_DIR}/INSTALL)
# Download and build yaml-cpp; set YAMLCPP_ROOT
ExternalProject_Add(
yamlcpp
URL https://yaml-cpp.googlecode.com/files/yaml-cpp-${YAMLCPP_VERSION}.tar.gz
URL_HASH SHA1=9c5414b4090491e96d1b808fe8628b31e625fdaa
DEPENDS boost
UPDATE_COMMAND ""
CMAKE_CACHE_ARGS -DBOOST_ROOT:PATH=${BOOST_ROOT} -DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_BINARY_DIR}/INSTALL
INSTALL_DIR ${CMAKE_BINARY_DIR}/INSTALL)
set(YAMLCPP_ROOT ${CMAKE_BINARY_DIR}/INSTALL)
# Download and build openssl, set OPENSSL_ROOT
# See http://developer.covenanteyes.com/building-openssl-for-visual-studio/ for Windows build instructions
set(OPENSSL_Config ./Configure)
if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(OPENSSL_Target darwin64-x86_64-cc)
endif()
ExternalProject_Add(
openssl
URL https://www.openssl.org/source/openssl-${OPENSSL_VERSION}.tar.gz
BUILD_IN_SOURCE 1
UPDATE_COMMAND ""
PATCH_COMMAND ""
CONFIGURE_COMMAND ${OPENSSL_Config}
--prefix=${CMAKE_BINARY_DIR}/INSTALL
--openssldir=${CMAKE_BINARY_DIR}/INSTALL/ssl
--libdir=lib
shared
${OPENSSL_Target}
zlib-dynamic
enable-camellia
enable-seed
enable-tlsext
enable-rfc3779
enable-cms
enable-md2
no-mdc2
no-rc5
no-ec2m
no-gost
no-srp
no-ssl2
BUILD_COMMAND make depend && make
INSTALL_COMMAND make install
INSTALL_DIR ${CMAKE_BINARY_DIR}/INSTALL)
set(OPENSSL_ROOT ${CMAKE_BINARY_DIR}/INSTALL)
endif()
# Download and stage gmock
#ExternalProject_Add(
# gmock
# URL https://googlemock.googlecode.com/files/gmock-1.7.0.zip
# UPDATE_COMMAND ""
# INSTALL_COMMAND "")
# Download and stage rapidjson
#ExternalProject_Add(
# rapidjson
# URL https://rapidjson.googlecode.com/files/rapidjson-0.11.zip
# URL_HASH SHA1=3348f4ce925ee0e58da123abfafe09ba203d4fc3
# CONFIGURE_COMMAND ""
# BUILD_COMMAND ""
# UPDATE_COMMAND ""
# INSTALL_COMMAND "")
# Download and build cfacter
ExternalProject_Add(
cfacter
DEPENDS boost yamlcpp openssl
GIT_REPOSITORY https://github.com/puppetlabs/cfacter
UPDATE_COMMAND ""
CMAKE_CACHE_ARGS -DBOOST_ROOT:PATH=${BOOST_ROOT} -DYAMLCPP_ROOT:PATH=${YAMLCPP_ROOT} -DOPENSSL_ROOT:PATH=${OPENSSL_ROOT} -DBOOST_STATIC=ON
INSTALL_COMMAND "")
@MikaelSmith
Copy link
Author

To use dynamic linking on mac, need to fix install_name. On Windows, put everything in the same directory, or include a startup script that shares a common directory.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment