Skip to content
Snippets Groups Projects
Commit dd4dcbf7 authored by Lars Bilke's avatar Lars Bilke
Browse files

WIP: Integrates Boost as an external CMake project.

This is a work in progress commit (tested on Mac OS) which shows how to build some boost libraries. Not all targets are changed accordingly but `make test` should work.
parent 08d6b48a
No related branches found
No related tags found
No related merge requests found
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#include "StringTools.h" #include "StringTools.h"
#include <sys/stat.h> #include <sys/stat.h>
#include <boost/filesystem.hpp>
namespace BaseLib namespace BaseLib
{ {
...@@ -24,27 +25,10 @@ namespace BaseLib ...@@ -24,27 +25,10 @@ namespace BaseLib
*/ */
bool IsFileExisting(const std::string &strFilename) bool IsFileExisting(const std::string &strFilename)
{ {
struct stat stFileInfo; if(boost::filesystem::exists(strFilename))
bool blnReturn; return true;
int intStat;
// Attempt to get the file attributes
intStat = stat(strFilename.c_str(),&stFileInfo);
if(intStat == 0)
// We were able to get the file attributes
// so the file obviously exists.
blnReturn = true;
else else
// We were not able to get the file attributes. return false;
// This may mean that we don't have permission to
// access the folder which contains this file. If you
// need to do that level of checking, lookup the
// return values of stat which will give you
// more details on why stat failed.
blnReturn = false;
return blnReturn;
} }
/** /**
......
...@@ -86,12 +86,17 @@ ENDIF() #OGS_PACKAGING ...@@ -86,12 +86,17 @@ ENDIF() #OGS_PACKAGING
### Subdirectories ### ### Subdirectories ###
###################### ######################
# External projects
INCLUDE(scripts/cmake/ExternalProjectBoost.cmake)
# Add subdirectories with the projects # Add subdirectories with the projects
ADD_SUBDIRECTORY( ThirdParty ) ADD_SUBDIRECTORY( ThirdParty )
INCLUDE_DIRECTORIES( ${CMAKE_SOURCE_DIR}/ThirdParty ) INCLUDE_DIRECTORIES( ${CMAKE_SOURCE_DIR}/ThirdParty )
INCLUDE_DIRECTORIES( ${CMAKE_SOURCE_DIR}/ThirdParty/quickcheck ) INCLUDE_DIRECTORIES( ${CMAKE_SOURCE_DIR}/ThirdParty/quickcheck )
ADD_SUBDIRECTORY( BaseLib ) ADD_SUBDIRECTORY( BaseLib )
# TODO This is a hack but we have to make sure that Boost is built first
ADD_DEPENDENCIES(BaseLib Boost)
ADD_SUBDIRECTORY( FemLib ) ADD_SUBDIRECTORY( FemLib )
ADD_SUBDIRECTORY( FileIO ) ADD_SUBDIRECTORY( FileIO )
ADD_SUBDIRECTORY( GeoLib ) ADD_SUBDIRECTORY( GeoLib )
......
...@@ -21,6 +21,7 @@ TARGET_LINK_LIBRARIES(testrunner ...@@ -21,6 +21,7 @@ TARGET_LINK_LIBRARIES(testrunner
GTest GTest
BaseLib BaseLib
GeoLib GeoLib
${Boost_LIBRARIES}
) )
# Add make-target test which runs the testrunner # Add make-target test which runs the testrunner
......
INCLUDE(ExternalProject)
# Set Boost version and which libraries to compile
SET(Boost_Version 1.49.0)
SET(BOOST_LIBS_TO_BUILD
--with-program_options
--with-filesystem
--with-system
--with-date_time
)
STRING(REPLACE "." "_" Boost_Version_Underscore ${Boost_Version})
# Set boost toolset
IF(MSVC)
SET(BOOST_TOOLSET msvc-10.0) # TODO: VS 2010 only
ENDIF()
IF(COMPILER_IS_GCC)
SET(BOOST_TOOLSET gcc)
ENDIF()
IF(APPLE)
SET(BOOST_TOOLSET darwin)
ENDIF()
# Set update command
IF(WIN32)
SET(BOOST_UPDATE_COMMAND bootstrap.bat)
ELSE()
SET(BOOST_UPDATE_COMMAND ./bootstrap.sh)
ENDIF()
# Set additional config options
SET(BOOST_CONFIG_OPTIONS "")
IF(WIN32)
IF(HAVE_64_BIT)
SET(BOOST_CONFIG_OPTIONS "architecture=x86 address-model=64")
ENDIF()
ENDIF()
ExternalProject_Add(Boost
PREFIX ${CMAKE_BINARY_DIR}/External/boost
URL http://downloads.sourceforge.net/project/boost/boost/${Boost_Version}/boost_${Boost_Version_Underscore}.zip
URL_MD5 854dcbbff31b896c85c38247060b7713
UPDATE_COMMAND "${BOOST_UPDATE_COMMAND}"
CONFIGURE_COMMAND ""
BUILD_COMMAND ./b2 ${BOOST_LIBS_TO_BUILD} toolset=${BOOST_TOOLSET} link=static stage ${BOOST_CONFIG_OPTIONS}
BUILD_IN_SOURCE 1
INSTALL_COMMAND ""
)
ExternalProject_Get_Property( Boost source_dir )
#IF(NOT Boost_INCLUDE_DIRS)
SET( Boost_INCLUDE_DIRS ${source_dir} CACHE INTERNAL "Boost include directories")
# TODO this has to be set manually!
FILE( GLOB Boost_LIBRARIES "${source_dir}/stage/lib/" "${source_dir}/stage/lib/*.a")
SET( Boost_LIBRARIES ${Boost_LIBRARIES} CACHE INTERNAL "Boost libraries")
MESSAGE(STATUS "Boost inc: ${Boost_INCLUDE_DIRS}")
MESSAGE(STATUS "Boost libs: ${Boost_LIBRARIES}")
#ENDIF()
INCLUDE_DIRECTORIES( ${Boost_INCLUDE_DIRS} )
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment