Skip to content

Commit

Permalink
Replace CPL_DLL definition with CTB_DLL
Browse files Browse the repository at this point in the history
Using `CPL_DLL` requires changing GDAL's `cpl_port.h` file which is a hack too
far on many systems so the change is encapsulated in `CTB_DLL`.  This also
re-enables CMake directives that are appropriate for toolchains other than
Visual Studio.
  • Loading branch information
Homme Zwaagstra committed Nov 19, 2014
1 parent 7f54ed5 commit 25e61a8
Show file tree
Hide file tree
Showing 10 changed files with 47 additions and 33 deletions.
29 changes: 20 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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")
Expand Down
13 changes: 3 additions & 10 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
3 changes: 2 additions & 1 deletion src/GDALTile.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

#include "gdal_priv.h"

#include "config.hpp" // for CTB_DLL
#include "Tile.hpp"

namespace ctb {
Expand All @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion src/GDALTiler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/GlobalGeodetic.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down
3 changes: 2 additions & 1 deletion src/GlobalMercator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
* @brief This defines the `GlobalMercator` class
*/

#include "config.hpp" // for CTB_DLL
#include "Grid.hpp"

namespace ctb {
Expand All @@ -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:

Expand Down
4 changes: 2 additions & 2 deletions src/TerrainTile.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/TerrainTiler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
14 changes: 14 additions & 0 deletions src/config.hpp.in
Original file line number Diff line number Diff line change
Expand Up @@ -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 <string>
#include <sstream>

Expand Down
8 changes: 1 addition & 7 deletions tools/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)
Expand Down

0 comments on commit 25e61a8

Please sign in to comment.