Commit beddc2af authored by Rashad Kanavath's avatar Rashad Kanavath

PKG: fixes for boost and shark build with cxx11

parent ba6da81e
include(CheckCXXSourceCompiles)
unset(OTB_HAS_CXX11 CACHE)
CHECK_CXX_SOURCE_COMPILES("
#ifdef _MSC_VER
#if _MSC_VER <= 1700
#error Compiler is not C++11 compliant
#endif
#else
#if __cplusplus <= 199711L
#error Compiler is not C++11 compliant
#endif
#endif
int main(int argc, char *argv[])
{
return 0;
}
"
OTB_HAS_CXX11 )
unset(OTB_CXX_HAS_UNIQUE_PTR CACHE)
CHECK_CXX_SOURCE_COMPILES("
#include <memory>
struct Foo
{
Foo() { }
~Foo() { }
};
int main(int argc, char *argv[])
{
std::unique_ptr<Foo> p(new Foo);
return 0;
}
"
OTB_CXX_HAS_UNIQUE_PTR )
unset(OTB_CXX_HAS_OVERRIDE_SPECIFIER CACHE)
CHECK_CXX_SOURCE_COMPILES("
struct A
{
A() { }
~A() { }
virtual void foo( ) { }
};
struct B : A
{
B() { }
~B() { }
void foo( ) override { }
};
int main(int argc, char *argv[])
{
A* p = new B;
p->foo();
return 0;
}
"
OTB_CXX_HAS_OVERRIDE_SPECIFIER )
unset(OTB_CXX_HAS_NULLPTR CACHE)
CHECK_CXX_SOURCE_COMPILES("
int main(int argc, char *argv[])
{
int *p = nullptr;
return 0;
}
"
OTB_CXX_HAS_NULLPTR )
# try_compile(
# OTB_HAS_CXX11
# ${CMAKE_CURRENT_BINARY_DIR}/CMake
# ${CMAKE_SOURCE_DIR}/CMake/otbTestUniquePtr.cpp
# )
try_compile(OTB_IS_UNIQUE_PTR_DEFINED ${CMAKE_CURRENT_BINARY_DIR}/CMake ${CMAKE_SOURCE_DIR}/CMake/otbTestUniquePtr.cpp)
try_compile(OTB_IS_OVERRIDE_DEFINED ${CMAKE_CURRENT_BINARY_DIR}/CMake ${CMAKE_SOURCE_DIR}/CMake/otbTestUniquePtr.cpp)
try_compile(OTB_IS_NULLPTR_DEFINED ${CMAKE_CURRENT_BINARY_DIR}/CMake ${CMAKE_SOURCE_DIR}/CMake/otbTestUniquePtr.cpp)
try_compile(OTB_HAS_CXX11 ${CMAKE_CURRENT_BINARY_DIR}/CMake ${CMAKE_SOURCE_DIR}/CMake/otbTestUniquePtr.cpp)
#if __cplusplus <= 199711L
#error Compiler is not C++11 compliant
#endif
int main(int argc, char *argv[])
{
return 0;
}
int main(int argc, char *argv[])
{
int *p = ITK_NULLPTR;
return 0;
}
#include <iostream>
struct A
{
A() {}
~A() {}
virtual void foo() { std::cout << "A::foo()\n"; }
};
struct B : A
{
B() {}
~B() {}
void foo() override { std::cout << "B::foo()\n"; }
};
int main(int argc, char *argv[])
{
A* p = new B;
p->foo();
return 0;
}
#include <iostream>
#include <memory>
struct Foo
{
Foo() { std::cout << "Constructor\n"; }
~Foo() { std::cout << "Destructor\n"; }
};
int main(int argc, char *argv[])
{
std::unique_ptr<Foo> p(new Foo);
return 0;
}
......@@ -2,7 +2,10 @@ otb_module_test()
if (Boost_UNIT_TEST_FRAMEWORK_FOUND)
add_executable(otbOGRTests otbOGRDataSourceWrapperNew.cxx)
target_link_libraries(otbOGRTests ${OTBGdalAdapters-Test_LIBRARIES})
target_link_libraries(
otbOGRTests
${OTBGdalAdapters-Test_LIBRARIES}
${Boost_UNIT_TEST_FRAMEWORK_LIBRARY} )
add_test(NAME coTuOGRDataSourceWrapperNew
COMMAND otbOGRTests coTuOGRDataSourceWrapperNew
......
......@@ -3,9 +3,14 @@ project(OTBBoost)
set(OTBBoost_SYSTEM_INCLUDE_DIRS ${Boost_INCLUDE_DIRS})
set(OTBBoost_INCLUDE_DIRS ${OTBBoost_SOURCE_DIR}/src)
if(Boost_LIBRARIES)
set(OTBBoost_LIBRARIES "${Boost_LIBRARIES}")
endif()
# Do not include boost libraries into full list of OTB_LIBRARIES
# That will drag them in linking all otb modules and executables which is bad.
# OTB uses only header only libraries of boost. A non-header only library
# named 'unit_testing_framework' is used in two tests.
# why drag a semi-standard c++ library for use in two tests?.
# if(Boost_LIBRARIES)
# set(OTBBoost_LIBRARIES "${Boost_LIBRARIES}")
# endif()
set(Boost_VERSION_STRING "${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION}.${Boost_SUBMINOR_VERSION}" CACHE INTERNAL "" FORCE)
......
......@@ -5,19 +5,19 @@ set(OTBMuParserX_LIBRARIES "${MUPARSERX_LIBRARIES}")
set(OTBMuParserX_INCLUDE_DIRS ${OTBMuParserX_BINARY_DIR}/src)
# as advised by Ingo Berg : avoid using those #define with MSVC
if(OTB_IS_UNIQUE_PTR_DEFINED OR MSVC)
if(OTB_CXX_HAS_UNIQUE_PTR OR MSVC)
set(OTB_MUPARSERX_HIDE_UNIQUE_PTR 0)
else()
set(OTB_MUPARSERX_HIDE_UNIQUE_PTR 1)
endif()
if(OTB_IS_OVERRIDE_DEFINED OR MSVC)
if(OTB_CXX_HAS_OVERRIDE_SPECIFIER OR MSVC)
set(OTB_MUPARSERX_HIDE_OVERRIDE 0)
else()
set(OTB_MUPARSERX_HIDE_OVERRIDE 1)
endif()
if(OTB_IS_NULLPTR_DEFINED OR MSVC)
if(OTB_CXX_HAS_NULLPTR OR MSVC)
set(OTB_MUPARSERX_HIDE_NULLPTR 0)
else()
set(OTB_MUPARSERX_HIDE_NULLPTR 1)
......
......@@ -2,30 +2,67 @@ INCLUDE_ONCE_MACRO(BOOST)
SETUP_SUPERBUILD(BOOST)
#all we loose is one single test from not building boost unit-testing-framework.
#That is single test code. I don't see why we can't use something in-house
#change test code to not use boost unit-testing-framework and all is well.
set(_SB_Boost_INCLUDE_DIR ${SB_INSTALL_PREFIX}/include)
set(_SB_BOOST_LIBRARYDIR ${SB_INSTALL_PREFIX}/lib)
set(BOOST_SB_CONFIG)
if(OTB_COMPILER_ARCH_IS_X64)
set(BOOST_SB_CONFIG architecture=x86 address-model=64)
else()
set(BOOST_SB_CONFIG architecture=x86)
endif()
set(BOOST_SB_CONFIG
${BOOST_SB_CONFIG}
variant=release
link=shared
threading=multi
runtime-link=shared
--prefix=${SB_INSTALL_PREFIX}
--includedir=${_SB_Boost_INCLUDE_DIR}
--libdir=${_SB_Boost_LIBRARY_DIR}
--with-system
--with-serialization
--with-filesystem
--with-test
--with-date_time
--with-program_options
--with-thread
-d0
)
if(MSVC)
set(BOOST_URL "http://download.sourceforge.net/project/boost/boost/1.60.0/boost_1_60_0.tar.bz2")
set(BOOST_URL_MD5 "65a840e1a0b13a558ff19eeb2c4f0cbe")
if(UNIX)
set(BOOST_BOOTSTRAP_FILE "./bootstrap.sh")
set(BOOST_B2_EXE "./b2")
else()
set(BOOST_URL "http://download.sourceforge.net/project/boost/boost/1.50.0/boost_1_50_0.tar.bz2")
set(BOOST_URL_MD5 "52dd00be775e689f55a987baebccc462")
set(BOOST_BOOTSTRAP_FILE "bootstrap.bat")
set(BOOST_B2_EXE "b2.exe")
endif()
set(BOOST_CONFIGURE_COMMAND ${CMAKE_COMMAND}
-E chdir ${BOOST_SB_SRC}
${BOOST_BOOTSTRAP_FILE}
--prefix=${SB_INSTALL_PREFIX}
)
set(BOOST_BUILD_COMMAND ${CMAKE_COMMAND}
-E chdir ${BOOST_SB_SRC}
${BOOST_B2_EXE}
${BOOST_SB_CONFIG}
install
)
ExternalProject_Add(BOOST
PREFIX BOOST
URL "${BOOST_URL}"
URL_MD5 ${BOOST_URL_MD5}
URL "http://download.sourceforge.net/project/boost/boost/1.60.0/boost_1_60_0.tar.bz2"
URL_MD5 65a840e1a0b13a558ff19eeb2c4f0cbe
BINARY_DIR ${BOOST_SB_BUILD_DIR}
INSTALL_DIR ${SB_INSTALL_PREFIX}
DOWNLOAD_DIR ${DOWNLOAD_LOCATION}
CMAKE_CACHE_ARGS ${SB_CMAKE_CACHE_ARGS}
PATCH_COMMAND ${CMAKE_COMMAND} -E copy
${CMAKE_SOURCE_DIR}/patches/BOOST/CMakeLists.txt
${BOOST_SB_SRC}
CONFIGURE_COMMAND ${BOOST_CONFIGURE_COMMAND}
BUILD_COMMAND ${BOOST_BUILD_COMMAND}
INSTALL_COMMAND ""
)
set(_SB_Boost_INCLUDE_DIR ${SB_INSTALL_PREFIX}/include)
set(_SB_Boost_LIBRARY_DIR ${SB_INSTALL_PREFIX}/lib)
SUPERBUILD_PATCH_SOURCE(BOOST)
\ No newline at end of file
......@@ -15,11 +15,11 @@ if(MSVC)
return()
endif()
if(OTB_MSVC_COMPILER_ARCH_IS_X64)
set(CURL_INSTALL_DIR_PREFIX "libcurl-vc-x64")
else()
set(CURL_INSTALL_DIR_PREFIX "libcurl-vc-x86")
endif()
if(OTB_COMPILER_ARCH_IS_X64)
set(CURL_INSTALL_DIR_PREFIX "libcurl-vc-x64")
else()
set(CURL_INSTALL_DIR_PREFIX "libcurl-vc-x86")
endif()
set(CURL_INSTALL_DIR_PREFIX "${CURL_INSTALL_DIR_PREFIX}-release-dll-zlib-dll-ipv6-sspi-winssl")
......@@ -39,6 +39,7 @@ endif()
)
else(UNIX)
ExternalProject_Add(CURL
PREFIX CURL
URL "http://curl.haxx.se/download/curl-7.40.0.tar.gz"
......
......@@ -92,10 +92,10 @@ else(MSVC)
STRING(REGEX REPLACE "/$" "" CMAKE_WIN_INSTALL_PREFIX ${SB_INSTALL_PREFIX})
STRING(REGEX REPLACE "/" "\\\\" CMAKE_WIN_INSTALL_PREFIX ${CMAKE_WIN_INSTALL_PREFIX})
configure_file(
${CMAKE_SOURCE_DIR}/patches/GDAL/nmake_gdal_extra.opt.in
${CMAKE_BINARY_DIR}/nmake_gdal_extra.opt)
${CMAKE_SOURCE_DIR}/patches/GDAL/nmake_gdal_extra.opt.in
${CMAKE_BINARY_DIR}/nmake_gdal_extra.opt)
if(OTB_MSVC_COMPILER_ARCH_IS_X64)
if(OTB_COMPILER_ARCH_IS_X64)
file(APPEND "${CMAKE_BINARY_DIR}/nmake_gdal_extra.opt" "WIN64=YES")
endif()
......
......@@ -44,6 +44,7 @@ endif()
if(OTB_USE_SHARK)
ADDTO_DEPENDENCIES_IF_NOT_SYSTEM(OTB SHARK)
ADD_SUPERBUILD_CMAKE_VAR(OTB Shark_DIR)
endif()
if(OTB_USE_LIBSVM)
......
......@@ -5,8 +5,10 @@ SETUP_SUPERBUILD(SHARK)
# declare dependencies
ADDTO_DEPENDENCIES_IF_NOT_SYSTEM(SHARK BOOST)
package_require_cxx11(SHARK)
ADD_SUPERBUILD_CMAKE_VAR(SHARK Boost_INCLUDE_DIR)
ADD_SUPERBUILD_CMAKE_VAR(SHARK Boost_LIBRARY_DIR)
ADD_SUPERBUILD_CMAKE_VAR(SHARK BOOST_LIBRARYDIR)
ExternalProject_Add(SHARK
PREFIX SHARK
......@@ -23,7 +25,8 @@ ExternalProject_Add(SHARK
-DBUILD_EXAMPLES:BOOL=OFF
-DBUILD_TESTING:BOOL=OFF
-DENABLE_HDF5:BOOL=OFF
-DENABLE_CBLAS:BOOL=OFF
CMAKE_COMMAND ${SB_CMAKE_COMMAND}
)
set(_SB_SHARK_DIR ${SB_INSTALL_PREFIX}/share/Shark)
set(_SB_Shark_DIR ${SB_INSTALL_PREFIX}/lib/cmake/Shark)
......@@ -174,3 +174,10 @@ macro(SUPERBUILD_UPDATE_CMAKE_VARIABLES PROJECT with_prefix)
set(_SB_${PROJECT}_LIBRARY ${SB_INSTALL_PREFIX}/lib/${lib_file})
endmacro()
macro(package_require_cxx11 project)
if(NOT OTB_HAS_CXX11)
message(FATAL_ERROR "${project} requires C++11 support. consider adding --std=c++11 to your cxx compiler flags or disable ${project} ")
endif()
endmacro()
......@@ -7,10 +7,13 @@ project(OTB-SuperBuild)
set(CMAKE_MODULE_PATH
${CMAKE_SOURCE_DIR}/CMake
${CMAKE_SOURCE_DIR}/../CMake
${CMAKE_MODULE_PATH})
${CMAKE_MODULE_PATH}
)
include(ExternalProject)
include(OTBCheckCpp11Keywords)
option(BUILD_SHARED_LIBS "Build OTB with shared libraries." ON)
set(OTB_ADDITIONAL_CACHE "" CACHE STRING "Additional cmake option for OTB -DVAR:TYPE=VALUE ...")
......@@ -22,19 +25,38 @@ if(APPLE)
set(CMAKE_MACOSX_RPATH TRUE)
endif()
set(OTB_COMPILER_ARCH_IS_X64 TRUE)
if(MSVC)
execute_process(
COMMAND ${CMAKE_C_COMPILER}
ERROR_VARIABLE ev
OUTPUT_VARIABLE ov
OUTPUT_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE)
COMMAND ${CMAKE_C_COMPILER}
ERROR_VARIABLE ev
OUTPUT_VARIABLE ov
OUTPUT_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE
)
set(OTB_MSVC_COMPILER_ARCH_IS_X64 TRUE)
set(OTB_COMPILER_ARCH_IS_X64 TRUE)
set(OTB_COMPILER_ARCH x64)
if("${ev}" MATCHES "x86")
set(OTB_MSVC_COMPILER_ARCH_IS_X64 FALSE)
set(OTB_COMPILER_ARCH x86)
set(OTB_COMPILER_ARCH_IS_X64 FALSE)
endif()
endif() #MSVC
if(UNIX)
execute_process(
COMMAND uname -m
ERROR_VARIABLE ev
OUTPUT_VARIABLE ov
OUTPUT_STRIP_TRAILING_WHITESPACE)
set(OTB_COMPILER_ARCH ${ov})
set(OTB_COMPILER_ARCH_IS_X64 FALSE)
if("${ov}" STREQUAL "x86_64")
set(OTB_COMPILER_ARCH_IS_X64 TRUE)
endif()
endif()
# use, i.e. don't skip the full RPATH for the build tree
......
cmake_minimum_required(VERSION 2.8.3)
project(OTB-SuperBuildBoost)
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/boost
DESTINATION ${CMAKE_INSTALL_PREFIX}/include
FILES_MATCHING PATTERN "*.hpp" PATTERN "*.ipp" PATTERN "*.h")
diff -burN boost_1_60_0.orig/tools/build/src/tools/darwin.jam boost_1_60_0/tools/build/src/tools/darwin.jam
--- boost_1_60_0.orig/tools/build/src/tools/darwin.jam 2016-10-11 14:27:28.000000000 +0200
+++ boost_1_60_0/tools/build/src/tools/darwin.jam 2016-10-11 14:27:40.000000000 +0200
@@ -579,7 +579,7 @@
actions link.dll bind LIBRARIES
{
- "$(CONFIG_COMMAND)" -dynamiclib -Wl,-single_module -install_name "$(<:B)$(<:S)" -L"$(LINKPATH)" -o "$(<)" "$(>)" "$(LIBRARIES)" -l$(FINDLIBS-SA) -l$(FINDLIBS-ST) $(FRAMEWORK_PATH) -framework$(_)$(FRAMEWORK:D=:S=) $(OPTIONS) $(USER_OPTIONS)
+ "$(CONFIG_COMMAND)" -dynamiclib -Wl,-single_module -install_name "@rpath/$(<:B)$(<:S)" -L"$(LINKPATH)" -o "$(<)" "$(>)" "$(LIBRARIES)" -l$(FINDLIBS-SA) -l$(FINDLIBS-ST) $(FRAMEWORK_PATH) -framework$(_)$(FRAMEWORK:D=:S=) $(OPTIONS) $(USER_OPTIONS)
}
# We use libtool instead of ar to support universal binary linking
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment