From e1572b1dcb887cca983cdefa0aca34b1168b27c5 Mon Sep 17 00:00:00 2001 From: sanak Date: Wed, 4 Jul 2012 12:33:19 +0900 Subject: [PATCH] fix for 1.x MinGW 32/64 build. --- CMakeLists.txt | 6 +-- cmake/FindCGAL.cmake | 42 +++++++++++++++---- core/src/astar_boost_wrapper.cpp | 5 ++- core/src/boost_wrapper.cpp | 5 ++- core/src/shooting_star_boost_wrapper.cpp | 5 ++- extra/driving_distance/src/CMakeLists.txt | 5 ++- extra/driving_distance/src/alpha.h | 3 ++ .../driving_distance/src/alpha_drivedist.cpp | 7 +++- .../driving_distance/src/boost_drivedist.cpp | 5 ++- extra/tsp/src/tsp_solver.cpp | 3 ++ 10 files changed, 64 insertions(+), 22 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9bb579a28cc..e0bd12563eb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -28,7 +28,7 @@ ELSE(Boost_INCLUDE_DIRS) MESSAGE(FATAL ERROR " Please check your Boost installation ") ENDIF(Boost_INCLUDE_DIRS) -EXEC_PROGRAM(pg_config +EXEC_PROGRAM(${POSTGRESQL_EXECUTABLE}/pg_config ARGS --pkglibdir OUTPUT_VARIABLE LIB_DIR) @@ -87,8 +87,8 @@ IF(WIN32) LINK_LIBRARIES(postgres) ENDIF(WIN32) -SET(CMAKE_C_FLAGS "-O2 -g -lgmp -frounding-math") -SET(CMAKE_CXX_FLAGS "-O2 -g -lgmp -frounding-math") +SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O2 -g -frounding-math") +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2 -g -frounding-math") # Recurse into the subdirectories. This does not actually # cause another cmake executable to run. The same process will walk through diff --git a/cmake/FindCGAL.cmake b/cmake/FindCGAL.cmake index f1189fba99a..671800a3c4e 100644 --- a/cmake/FindCGAL.cmake +++ b/cmake/FindCGAL.cmake @@ -5,10 +5,10 @@ # CGAL_LIBRARIES, the libraries needed to use CGAL. # CGAL_FOUND, If false, do not try to use CGAL. -if(CGAL_INCLUDE_DIR AND CGAL_LIBRARIES) +if(CGAL_INCLUDE_DIR AND CGAL_LIBRARIES AND BOOST_THREAD_LIBRARIES AND GMP_LIBRARIES) set(CGAL_FOUND TRUE) -else(CGAL_INCLUDE_DIR AND CGAL_LIBRARIES) +else(CGAL_INCLUDE_DIR AND CGAL_LIBRARIES AND BOOST_THREAD_LIBRARIES AND GMP_LIBRARIES) FIND_PATH(CGAL_INCLUDE_DIR CGAL/basic.h /usr/include @@ -28,16 +28,40 @@ else(CGAL_INCLUDE_DIR AND CGAL_LIBRARIES) $ENV{ProgramFiles}/CGAL/*/lib $ENV{SystemDrive}/CGAL/*/lib ) - - if(CGAL_INCLUDE_DIR AND CGAL_LIBRARIES) + + find_library(BOOST_THREAD_LIBRARIES NAMES boost_thread libboost_thread + PATHS + /usr/lib + /usr/local/lib + /usr/lib/boost + /usr/lib64 + /usr/local/lib64 + /usr/lib64/boost + $ENV{ProgramFiles}/boost/*/lib + $ENV{SystemDrive}/boost/*/lib + ) + + find_library(GMP_LIBRARIES NAMES gmp libgmp + PATHS + /usr/lib + /usr/local/lib + /usr/lib/gmp + /usr/lib64 + /usr/local/lib64 + /usr/lib64/gmp + $ENV{ProgramFiles}/gmp/*/lib + $ENV{SystemDrive}/gmp/*/lib + ) + + if(CGAL_INCLUDE_DIR AND CGAL_LIBRARIES AND BOOST_THREAD_LIBRARIES AND GMP_LIBRARIES) set(CGAL_FOUND TRUE) - message(STATUS "Found CGAL: ${CGAL_INCLUDE_DIR}, ${CGAL_LIBRARIES}") + message(STATUS "Found CGAL: ${CGAL_INCLUDE_DIR}, ${CGAL_LIBRARIES}, ${BOOST_THREAD_LIBRARIES}, ${GMP_LIBRARIES}") INCLUDE_DIRECTORIES(${CGAL_INCLUDE_DIR} $ENV{CGAL_CFG}) - else(CGAL_INCLUDE_DIR AND CGAL_LIBRARIES) + else(CGAL_INCLUDE_DIR AND CGAL_LIBRARIES AND BOOST_THREAD_LIBRARIES AND GMP_LIBRARIES) set(CGAL_FOUND FALSE) message(STATUS "CGAL not found.") - endif(CGAL_INCLUDE_DIR AND CGAL_LIBRARIES) + endif(CGAL_INCLUDE_DIR AND CGAL_LIBRARIES AND BOOST_THREAD_LIBRARIES AND GMP_LIBRARIES) - mark_as_advanced(CGAL_INCLUDE_DIR CGAL_LIBRARIES) + mark_as_advanced(CGAL_INCLUDE_DIR CGAL_LIBRARIES BOOST_THREAD_LIBRARIES GMP_LIBRARIES) -endif(CGAL_INCLUDE_DIR AND CGAL_LIBRARIES) +endif(CGAL_INCLUDE_DIR AND CGAL_LIBRARIES AND BOOST_THREAD_LIBRARIES AND GMP_LIBRARIES) diff --git a/core/src/astar_boost_wrapper.cpp b/core/src/astar_boost_wrapper.cpp index 9bc3cb04ab6..a342cdaabb1 100644 --- a/core/src/astar_boost_wrapper.cpp +++ b/core/src/astar_boost_wrapper.cpp @@ -19,14 +19,15 @@ * */ +// Include C header first for windows build issue +#include "astar.h" + #include #include #include #include -#include "astar.h" - #include // for sqrt using namespace std; diff --git a/core/src/boost_wrapper.cpp b/core/src/boost_wrapper.cpp index e8b65ee133d..fee74e127f3 100644 --- a/core/src/boost_wrapper.cpp +++ b/core/src/boost_wrapper.cpp @@ -19,14 +19,15 @@ * */ +// Include C header first for windows build issue +#include "dijkstra.h" + #include #include #include #include -#include "dijkstra.h" - using namespace std; using namespace boost; diff --git a/core/src/shooting_star_boost_wrapper.cpp b/core/src/shooting_star_boost_wrapper.cpp index 322428e62e3..8b5a8319df9 100644 --- a/core/src/shooting_star_boost_wrapper.cpp +++ b/core/src/shooting_star_boost_wrapper.cpp @@ -19,6 +19,9 @@ * */ +// Include C header first for windows build issue +#include "shooting_star.h" + #include #include @@ -26,8 +29,6 @@ #include #include -#include "shooting_star.h" - #include // for sqrt using namespace std; diff --git a/extra/driving_distance/src/CMakeLists.txt b/extra/driving_distance/src/CMakeLists.txt index 6db72ae2776..32c9182465e 100644 --- a/extra/driving_distance/src/CMakeLists.txt +++ b/extra/driving_distance/src/CMakeLists.txt @@ -1,4 +1,7 @@ SET(LIBRARY_OUTPUT_PATH ../../../lib/) -LINK_LIBRARIES(${CGAL_LIBRARIES}) +LINK_LIBRARIES(${CGAL_LIBRARIES} ${GMP_LIBRARIES} ${BOOST_THREAD_LIBRARIES}) ADD_LIBRARY(routing_dd SHARED alpha.c alpha_drivedist.cpp alpha.h boost_drivedist.cpp drivedist.c drivedist.h) +IF(WIN32) + SET_TARGET_PROPERTIES(routing_dd PROPERTIES COMPILE_FLAGS "-DBOOST_THREAD_USE_LIB -DBoost_USE_STATIC_LIBS -DBOOST_USE_WINDOWS_H") +ENDIF(WIN32) INSTALL(TARGETS routing_dd DESTINATION ${LIBRARY_INSTALL_PATH}) diff --git a/extra/driving_distance/src/alpha.h b/extra/driving_distance/src/alpha.h index 32ea0d23971..467fdb474e2 100644 --- a/extra/driving_distance/src/alpha.h +++ b/extra/driving_distance/src/alpha.h @@ -21,6 +21,9 @@ #define _ALPHA_H +#ifdef __MINGW64__ +#define ELOG_H +#endif #include "postgres.h" #include "dijkstra.h" diff --git a/extra/driving_distance/src/alpha_drivedist.cpp b/extra/driving_distance/src/alpha_drivedist.cpp index d8b0ee02efc..b41b0b9990f 100644 --- a/extra/driving_distance/src/alpha_drivedist.cpp +++ b/extra/driving_distance/src/alpha_drivedist.cpp @@ -30,7 +30,12 @@ Takes a list of points and returns a list of segments corresponding to the Alpha shape. ************************************************************************/ - +#ifdef __MINGW64__ +#include +namespace boost { + void tss_cleanup_implemented() { } +} +#endif #include #include #include diff --git a/extra/driving_distance/src/boost_drivedist.cpp b/extra/driving_distance/src/boost_drivedist.cpp index 8684d8bbb32..b9f74c03e33 100644 --- a/extra/driving_distance/src/boost_drivedist.cpp +++ b/extra/driving_distance/src/boost_drivedist.cpp @@ -19,14 +19,15 @@ * */ +// Include C header first for windows build issue +#include "drivedist.h" + #include #include #include #include -#include "drivedist.h" - using namespace std; using namespace boost; diff --git a/extra/tsp/src/tsp_solver.cpp b/extra/tsp/src/tsp_solver.cpp index 9ef21c3e121..8c58c47e251 100644 --- a/extra/tsp/src/tsp_solver.cpp +++ b/extra/tsp/src/tsp_solver.cpp @@ -22,6 +22,9 @@ extern "C" { #include +#ifdef __MINGW64__ +#define ELOG_H +#endif #include }