diff --git a/BaseLib/FileTools.cpp b/BaseLib/FileTools.cpp index f5cf869322293755ce5116b13c790cc706c7ae67..5ed8ee7458928156326618b935811972f39e546a 100644 --- a/BaseLib/FileTools.cpp +++ b/BaseLib/FileTools.cpp @@ -16,6 +16,7 @@ #include "StringTools.h" #include <sys/stat.h> +#include <boost/filesystem.hpp> namespace BaseLib { @@ -24,27 +25,10 @@ namespace BaseLib */ bool IsFileExisting(const std::string &strFilename) { - struct stat stFileInfo; - bool blnReturn; - 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; + if(boost::filesystem::exists(strFilename)) + return true; else - // We were not able to get the file attributes. - // 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; + return false; } /** diff --git a/CMakeLists.txt b/CMakeLists.txt index 31767af1e6abb600fff1e615a83010cbba2a3f66..3cd4d839d05bc69f31d643d90216f1e1d84604e7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -86,12 +86,17 @@ ENDIF() #OGS_PACKAGING ### Subdirectories ### ###################### +# External projects +INCLUDE(scripts/cmake/ExternalProjectBoost.cmake) + # Add subdirectories with the projects ADD_SUBDIRECTORY( ThirdParty ) INCLUDE_DIRECTORIES( ${CMAKE_SOURCE_DIR}/ThirdParty ) INCLUDE_DIRECTORIES( ${CMAKE_SOURCE_DIR}/ThirdParty/quickcheck ) 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( FileIO ) ADD_SUBDIRECTORY( GeoLib ) diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 69f73c75decf7cc4fc2b9fb63c03d77db50fdf67..c4761122e35f89b398dc96b0196e43ee838dc907 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -21,6 +21,7 @@ TARGET_LINK_LIBRARIES(testrunner GTest BaseLib GeoLib + ${Boost_LIBRARIES} ) # Add make-target test which runs the testrunner diff --git a/scripts/cmake/ExternalProjectBoost.cmake b/scripts/cmake/ExternalProjectBoost.cmake new file mode 100644 index 0000000000000000000000000000000000000000..0b658fecec06b1d842886d8d334eabdf83856800 --- /dev/null +++ b/scripts/cmake/ExternalProjectBoost.cmake @@ -0,0 +1,61 @@ +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