diff --git a/CMakeLists.txt b/CMakeLists.txt index edb3ff8..9cc1c60 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,13 +12,15 @@ include(CheckCXXCompilerFlag) CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11) CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X) -#if(COMPILER_SUPPORTS_CXX11) -# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") -#elseif(COMPILER_SUPPORTS_CXX0X) -# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x") -#else() -# message(FATAL_ERROR "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.") -#endif() +if(NOT MSVC) + if(COMPILER_SUPPORTS_CXX11) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") + elseif(COMPILER_SUPPORTS_CXX0X) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x") + else() + message(FATAL_ERROR "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.") + endif() +endif() # We need g++ >= version 4.7 (see # http://stackoverflow.com/questions/4058565/check-gcc-minor-in-cmake) @@ -52,8 +54,17 @@ install(FILES ${PROJECT_BINARY_DIR}/config.hpp DESTINATION include/ctb) # Perform as many checks as possible on debug builds: # cmake -DCMAKE_BUILD_TYPE=Debug .. -#set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wall -Wextra --pedantic") -#set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Wall -Wextra --pedantic") +if(NOT MSVC) + set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wall -Wextra --pedantic") + #set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Wall -Wextra --pedantic") +endif() + +# We need GDAL +find_package(GDAL) +if(NOT GDAL_FOUND) + message(FATAL_ERROR "The GDAL library cannot be found on the system") +endif() +include_directories(${GDAL_INCLUDE_DIRS}) # Build and install libctb include_directories("${PROJECT_SOURCE_DIR}/src") diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 0ac9970..cce4979 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,17 +1,10 @@ -# We need GDAL -find_package(GDAL) -if(NOT GDAL_FOUND) - message(FATAL_ERROR "The GDAL library cannot be found on the system") -endif() -include_directories(${GDAL_INCLUDE_DIRS}) - # Ensure we have a unified GDAL: `GDALOpenEx` is only present after # unification. include(CheckLibraryExists) check_library_exists(gdal GDALOpenEx "gdal.h" HAVE_UNIFIED_GDAL) -#if(NOT HAVE_UNIFIED_GDAL) -# message(FATAL_ERROR "The GDAL version must be one that implements RFC 46 (GDAL/OGR unification) i.e. >= 2.0.0") -#endif(NOT HAVE_UNIFIED_GDAL) +if(NOT MSVC AND NOT HAVE_UNIFIED_GDAL) + message(FATAL_ERROR "The GDAL version must be one that implements RFC 46 (GDAL/OGR unification) i.e. >= 2.0.0") +endif() # We need zlib find_package(ZLIB) diff --git a/src/GDALTile.hpp b/src/GDALTile.hpp index cfe5081..86ba270 100644 --- a/src/GDALTile.hpp +++ b/src/GDALTile.hpp @@ -24,6 +24,7 @@ #include "gdal_priv.h" +#include "config.hpp" // for CTB_DLL #include "Tile.hpp" namespace ctb { @@ -41,7 +42,7 @@ namespace ctb { * linear approximation) which wraps an image transformer. The VRT owns any top * level transformer, but we are responsible for the wrapped image transformer. */ -class CPL_DLL ctb::GDALTile : +class CTB_DLL ctb::GDALTile : public Tile { public: diff --git a/src/GDALTiler.hpp b/src/GDALTiler.hpp index 7857cd5..a5b66c9 100644 --- a/src/GDALTiler.hpp +++ b/src/GDALTiler.hpp @@ -59,7 +59,7 @@ struct ctb::TilerOptions { * the reference count is decremented and, if it reaches `0`, the dataset is * closed. */ -class CPL_DLL ctb::GDALTiler { +class CTB_DLL ctb::GDALTiler { public: /// Instantiate a tiler with all required arguments diff --git a/src/GlobalGeodetic.hpp b/src/GlobalGeodetic.hpp index 4b085c4..4f3ae3e 100644 --- a/src/GlobalGeodetic.hpp +++ b/src/GlobalGeodetic.hpp @@ -35,7 +35,7 @@ namespace ctb { * This class models the [Tile Mapping Service Global Geodetic * Profile](http://wiki.osgeo.org/wiki/Tile_Map_Service_Specification#global-geodetic). */ -class CPL_DLL ctb::GlobalGeodetic : +class CTB_DLL ctb::GlobalGeodetic : public Grid { public: diff --git a/src/GlobalMercator.hpp b/src/GlobalMercator.hpp index 2c793ce..4d1e590 100644 --- a/src/GlobalMercator.hpp +++ b/src/GlobalMercator.hpp @@ -22,6 +22,7 @@ * @brief This defines the `GlobalMercator` class */ +#include "config.hpp" // for CTB_DLL #include "Grid.hpp" namespace ctb { @@ -34,7 +35,7 @@ namespace ctb { * This class models the [Tile Mapping Service Global Mercator * Profile](http://wiki.osgeo.org/wiki/Tile_Map_Service_Specification#global-mercator). */ -class CPL_DLL ctb::GlobalMercator : +class CTB_DLL ctb::GlobalMercator : public Grid { public: diff --git a/src/TerrainTile.hpp b/src/TerrainTile.hpp index 09c9fa1..5941166 100644 --- a/src/TerrainTile.hpp +++ b/src/TerrainTile.hpp @@ -41,7 +41,7 @@ namespace ctb { * This aims to implement the Cesium [heightmap-1.0 terrain * format](http://cesiumjs.org/data-and-assets/terrain/formats/heightmap-1.0.html). */ -class CPL_DLL ctb::Terrain { +class CTB_DLL ctb::Terrain { public: /// Create an empty terrain object @@ -180,7 +180,7 @@ class CPL_DLL ctb::Terrain { * Associating terrain data with a tile coordinate allows the tile to be * converted to a geo-referenced raster (see `TerrainTile::heightsToRaster`). */ -class CPL_DLL ctb::TerrainTile : +class CTB_DLL ctb::TerrainTile : public Terrain, public Tile { friend class TerrainTiler; diff --git a/src/TerrainTiler.hpp b/src/TerrainTiler.hpp index c44e6e8..00da46b 100644 --- a/src/TerrainTiler.hpp +++ b/src/TerrainTiler.hpp @@ -36,7 +36,7 @@ namespace ctb { * `GDALTiler::createTerrainTile` method enabling `TerrainTile`s to be created * for a specific `TileCoordinate`. */ -class CPL_DLL ctb::TerrainTiler : +class CTB_DLL ctb::TerrainTiler : public GDALTiler { public: diff --git a/src/config.hpp.in b/src/config.hpp.in index 0c693f8..55034a2 100644 --- a/src/config.hpp.in +++ b/src/config.hpp.in @@ -25,6 +25,20 @@ * `config.hpp`. */ +/* Enable symbol export in Visual Studio 2013 as per issue #6. This is an + adaptation of `CPL_DLL` in GDAL's `cpl_port.h`. */ +#ifndef CTB_DLL +#if defined(_MSC_VER) +# if !defined(CPL_DISABLE_DLL) +# define CTB_DLL __declspec(dllexport) +# else +# define CTB_DLL __declspec(dllimport) +# endif +#else +# define CTB_DLL +#endif +#endif + #include #include diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt index 016d5b1..f973025 100644 --- a/tools/CMakeLists.txt +++ b/tools/CMakeLists.txt @@ -1,10 +1,4 @@ -# We need GDAL -find_package(GDAL) -if(NOT GDAL_FOUND) - message(FATAL_ERROR "The GDAL library cannot be found on the system") -endif() -include_directories(${GDAL_INCLUDE_DIRS}) - +# The tools are not shared libraries add_definitions(-DCPL_DISABLE_DLL) set(TOOL_TARGETS commander ctb)