Skip to content

Commit

Permalink
GEODE-4916: Fixes compilation errors when including in empty VC++ pro…
Browse files Browse the repository at this point in the history
…ject. (#258)

- Convert to CMake GenerateExportHeader.
- Generates platform specfic export files.
- Remove use of sprintf which caused error on Windows.
- Fixes explicit instantiation export attributes.
- Fixes default visibility.
  • Loading branch information
jake-at-work authored Apr 4, 2018
1 parent fc9c81c commit 19165e2
Show file tree
Hide file tree
Showing 228 changed files with 572 additions and 700 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -260,14 +260,14 @@ add_subdirectory(cppcache)
add_subdirectory(cryptoimpl)
add_subdirectory(dhimpl)
add_subdirectory(sqliteimpl)
add_subdirectory(tests)
add_subdirectory(templates/security)
add_subdirectory(docs/api)
add_subdirectory(examples)
if (${BUILD_CLI})
add_subdirectory(clicache)
add_subdirectory(plugins/SQLiteCLI)
endif()
add_subdirectory(tests)

install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/xsds/ DESTINATION xsds)
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/defaultSystem/ DESTINATION defaultSystem)
Expand Down
15 changes: 9 additions & 6 deletions clicache/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/AssemblyInfo.cpp.in ${CMAKE_CURRENT_B
list(APPEND CONFIGURE_IN_FILES ${CMAKE_CURRENT_SOURCE_DIR}/AssemblyInfo.cpp.in)
list(APPEND CONFIGURE_OUT_FILES ${CMAKE_CURRENT_BINARY_DIR}/AssemblyInfo.cpp)

add_library(${PROJECT_NAME} MODULE
add_library(Apache.Geode.Test MODULE
AssemblyInfo.cpp.in
native_conditional_unqiue_ptrTests.cpp
native_shared_ptrTests.cpp
Expand All @@ -32,32 +32,35 @@ add_library(${PROJECT_NAME} MODULE
${CONFIGURE_OUT_FILES}
)

set_target_properties(${PROJECT_NAME} PROPERTIES
set_target_properties(Apache.Geode.Test PROPERTIES
VS_GLOBAL_CLRSupport "true"
VS_GLOBAL_KEYWORD "ManagedCProj"
VS_GLOBAL_TestProjectType UnitTest
VS_GLOBAL_PROJECT_TYPES "{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}"
VS_GLOBAL_ROOTNAMESPACE ${PROJECT_NAME}
VS_GLOBAL_ROOTNAMESPACE Apache.Geode.Test
VS_DOTNET_TARGET_FRAMEWORK_VERSION "v4.5.2"
VS_DOTNET_REFERENCES "System;System.Xml;Microsoft.VisualStudio.QualityTools.UnitTestFramework"
)

target_include_directories(${PROJECT_NAME}
target_include_directories(Apache.Geode.Test
PRIVATE
$<TARGET_PROPERTY:apache-geode,SOURCE_DIR>
$<TARGET_PROPERTY:apache-geode,INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:Apache.Geode,SOURCE_DIR>
)

target_link_libraries(${PROJECT_NAME}
target_link_libraries(Apache.Geode.Test
PUBLIC
Apache.Geode
# Apache.Geode #- Causes include of .lib
PRIVATE
c++cli
c++11
_WarningsAsError
)

# Makes project only reference, no .lib.
add_dependencies(Apache.Geode.Test Apache.Geode)

string(REPLACE "/RTC1" "" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}")
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} ${SHARED_LINKER_FLAGS_STRONG_KEY}")

Expand Down
12 changes: 7 additions & 5 deletions cppcache/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ list(APPEND CONFIGURE_IN_FILES ${COMMON_SOURCE_DIR}/config.h.in)
list(APPEND CONFIGURE_OUT_FILES ${CMAKE_CURRENT_BINARY_DIR}/config.h)
configure_file(${COMMON_SOURCE_DIR}/config.h.in ${CMAKE_CURRENT_BINARY_DIR}/config.h)

set(EXPORT_FILE_NAME ${CMAKE_CURRENT_BINARY_DIR}/apache-geode_export.h)
list(APPEND CONFIGURE_OUT_FILES ${EXPORT_FILE_NAME})

set_source_files_properties(${CONFIGURE_OUT_FILES} PROPERTIES GENERATED TRUE)

set(SOURCES_ALL ${SOURCES} ${PRIVATE_HEADERS} ${PUBLIC_HEADERS} ${CONFIGURE_IN_FILES} ${CONFIGURE_OUT_FILES})
Expand Down Expand Up @@ -86,11 +89,6 @@ target_link_libraries(_apache-geode INTERFACE
libxml2
)

target_compile_definitions(_apache-geode INTERFACE
# TODO replace BUILD_CPPCACHE with built-in _DLL
$<BUILD_INTERFACE:BUILD_CPPCACHE>
)

if (USE_PCH)
# TODO figure out why PCH causes these warnings
# Ignore warnings resulting from using PCH
Expand All @@ -107,6 +105,10 @@ target_include_directories(_apache-geode INTERFACE
add_dependencies(_apache-geode version-header)

install(DIRECTORY ${COMMON_INCLUDE_DIR} DESTINATION .)
install(FILES
${EXPORT_FILE_NAME}
DESTINATION include/geode/internal
)

add_subdirectory(shared)
add_subdirectory(static)
Expand Down
2 changes: 1 addition & 1 deletion cppcache/include/geode/AttributesMutator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class Region;
* @see RegionAttributes
* @see RegionAttributesFactory
*/
class _GEODE_EXPORT AttributesMutator {
class APACHE_GEODE_EXPORT AttributesMutator {
private:
std::shared_ptr<Region> m_region;

Expand Down
2 changes: 1 addition & 1 deletion cppcache/include/geode/AuthInitialize.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class Properties;
* AuthInitialize object) as the <code>security-client-auth-factory</code>
* system property.
*/
class _GEODE_EXPORT AuthInitialize {
class APACHE_GEODE_EXPORT AuthInitialize {
public:
/**@brief initialize with the given set of security properties
* and return the credentials for the client as properties.
Expand Down
2 changes: 1 addition & 1 deletion cppcache/include/geode/AuthenticatedView.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class FunctionServiceImpl;
* <p>A cache can have multiple root regions, each with a different name.
*
*/
class _GEODE_EXPORT AuthenticatedView : public RegionService {
class APACHE_GEODE_EXPORT AuthenticatedView : public RegionService {
/**
* @brief public methods
*/
Expand Down
2 changes: 1 addition & 1 deletion cppcache/include/geode/Cache.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class AuthenticatedView;
* <p>A cache can have multiple root regions, each with a different name.
*
*/
class _GEODE_EXPORT Cache : public GeodeCache {
class APACHE_GEODE_EXPORT Cache : public GeodeCache {
/**
* @brief public methods
*/
Expand Down
2 changes: 1 addition & 1 deletion cppcache/include/geode/CacheAttributes.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ namespace client {
*/
class CacheAttributesFactory;

class _GEODE_EXPORT CacheAttributes {
class APACHE_GEODE_EXPORT CacheAttributes {
/**
* @brief public static methods
*/
Expand Down
2 changes: 1 addition & 1 deletion cppcache/include/geode/CacheFactory.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class AuthInitialize;
* For the default values for the pool attributes see {@link PoolFactory}.
* To create additional {@link Pool}s see {@link PoolManager}
*/
class _GEODE_EXPORT CacheFactory {
class APACHE_GEODE_EXPORT CacheFactory {
public:
/**
* To create the instance of {@link CacheFactory}
Expand Down
2 changes: 1 addition & 1 deletion cppcache/include/geode/CacheListener.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class RegionEvent;
* @see RegionAttributes::getCacheListener
* @see CacheListenerException
*/
class _GEODE_EXPORT CacheListener {
class APACHE_GEODE_EXPORT CacheListener {
/**
* @brief public methods
*/
Expand Down
2 changes: 1 addition & 1 deletion cppcache/include/geode/CacheLoader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class Region;
* @see RegionAttributesFactory::setCacheLoader
* @see RegionAttributes::getCacheLoader
*/
class _GEODE_EXPORT CacheLoader {
class APACHE_GEODE_EXPORT CacheLoader {
public:
/**Loads a value. Application writers should implement this
* method to customize the loading of a value. This method is called
Expand Down
2 changes: 1 addition & 1 deletion cppcache/include/geode/CacheStatistics.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class LocalRegion;
*@see Region::getStatistics
*@see RegionEntry::getStatistics
*/
class _GEODE_EXPORT CacheStatistics {
class APACHE_GEODE_EXPORT CacheStatistics {
public:
typedef std::chrono::system_clock::time_point time_point;

Expand Down
2 changes: 1 addition & 1 deletion cppcache/include/geode/CacheTransactionManager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ namespace apache {
namespace geode {
namespace client {

class _GEODE_EXPORT CacheTransactionManager {
class APACHE_GEODE_EXPORT CacheTransactionManager {
public:
/** Creates a new transaction and associates it with the current thread.
*
Expand Down
2 changes: 1 addition & 1 deletion cppcache/include/geode/CacheWriter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class Region;
* @see RegionAttributes::getCacheWriter
* @see AttributesMutator::setCacheWriter
*/
class _GEODE_EXPORT CacheWriter {
class APACHE_GEODE_EXPORT CacheWriter {
public:
/**
* Called before an entry is updated. The entry update is initiated by a
Expand Down
67 changes: 32 additions & 35 deletions cppcache/include/geode/CacheableBuiltins.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,8 @@ namespace geode {
namespace client {

/** Template CacheableKey class for primitive types. */
template <typename TObj, int8_t TYPEID, const char* TYPENAME,
const char* SPRINTFSYM, int32_t STRSIZE>
class CacheableKeyType : public CacheableKey {
template <typename TObj, int8_t TYPEID, const char* TYPENAME>
class APACHE_GEODE_EXPORT CacheableKeyType : public CacheableKey {
protected:
TObj m_value;

Expand Down Expand Up @@ -83,9 +82,7 @@ class CacheableKeyType : public CacheableKey {

/** Return a string representation of the object. */
virtual std::string toString() const override {
char buffer[STRSIZE + 1];
std::sprintf(buffer, SPRINTFSYM, m_value);
return std::string(buffer);
return std::to_string(m_value);
}

// CacheableKey methods
Expand Down Expand Up @@ -143,7 +140,7 @@ inline void copyArray(std::shared_ptr<TObj>* dest,

/** Template class for container Cacheable types. */
template <typename TBase, int8_t TYPEID>
class CacheableContainerType : public Cacheable, public TBase {
class APACHE_GEODE_EXPORT CacheableContainerType : public Cacheable, public TBase {
protected:
inline CacheableContainerType() : TBase() {}

Expand Down Expand Up @@ -196,16 +193,15 @@ class CacheableContainerType : public Cacheable, public TBase {
#pragma warning(disable : 4231)
#endif

#define _GEODE_CACHEABLE_KEY_TYPE_DEF_(p, k, sz) \
extern const char tName_##k[]; \
extern const char tStr_##k[]; \
template class _GEODE_EXPORT \
CacheableKeyType<p, GeodeTypeIds::k, tName_##k, tStr_##k, sz>; \
typedef CacheableKeyType<p, GeodeTypeIds::k, tName_##k, tStr_##k, sz> _##k;
#define _GEODE_CACHEABLE_KEY_TYPE_DEF_(p, k) \
extern const char tName_##k[]; \
template class \
CacheableKeyType<p, GeodeTypeIds::k, tName_##k>; \
typedef CacheableKeyType<p, GeodeTypeIds::k, tName_##k> _##k;

// use a class instead of typedef for bug #283
#define _GEODE_CACHEABLE_KEY_TYPE_(p, k, sz) \
class _GEODE_EXPORT k : public _##k { \
#define _GEODE_CACHEABLE_KEY_TYPE_(p, k) \
class APACHE_GEODE_EXPORT k : public _##k { \
protected: \
inline k() : _##k() {} \
inline k(const p value) : _##k(value) {} \
Expand Down Expand Up @@ -234,13 +230,14 @@ class CacheableContainerType : public Cacheable, public TBase {
return k::create(value); \
}

#define _GEODE_CACHEABLE_CONTAINER_TYPE_DEF_(p, c) \
template class _GEODE_EXPORT CacheableContainerType<p, GeodeTypeIds::c>; \
#define _GEODE_CACHEABLE_CONTAINER_TYPE_DEF_(p, c) \
template class \
CacheableContainerType<p, GeodeTypeIds::c>; \
typedef CacheableContainerType<p, GeodeTypeIds::c> _##c;

// use a class instead of typedef for bug #283
#define _GEODE_CACHEABLE_CONTAINER_TYPE_(p, c) \
class _GEODE_EXPORT c : public _##c { \
class APACHE_GEODE_EXPORT c : public _##c { \
protected: \
inline c() : _##c() {} \
inline c(const int32_t n) : _##c(n) {} \
Expand All @@ -264,66 +261,66 @@ class CacheableContainerType : public Cacheable, public TBase {

// Instantiations for the built-in CacheableKeys

_GEODE_CACHEABLE_KEY_TYPE_DEF_(bool, CacheableBoolean, 3);
_GEODE_CACHEABLE_KEY_TYPE_DEF_(bool, CacheableBoolean);
/**
* An immutable wrapper for booleans that can serve as
* a distributable key object for caching.
*/
_GEODE_CACHEABLE_KEY_TYPE_(bool, CacheableBoolean, 3);
_GEODE_CACHEABLE_KEY_TYPE_(bool, CacheableBoolean);

_GEODE_CACHEABLE_KEY_TYPE_DEF_(int8_t, CacheableByte, 15);
_GEODE_CACHEABLE_KEY_TYPE_DEF_(int8_t, CacheableByte);
/**
* An immutable wrapper for bytes that can serve as
* a distributable key object for caching.
*/
_GEODE_CACHEABLE_KEY_TYPE_(int8_t, CacheableByte, 15);
_GEODE_CACHEABLE_KEY_TYPE_(int8_t, CacheableByte);

_GEODE_CACHEABLE_KEY_TYPE_DEF_(double, CacheableDouble, 63);
_GEODE_CACHEABLE_KEY_TYPE_DEF_(double, CacheableDouble);
/**
* An immutable wrapper for doubles that can serve as
* a distributable key object for caching.
*/
_GEODE_CACHEABLE_KEY_TYPE_(double, CacheableDouble, 63);
_GEODE_CACHEABLE_KEY_TYPE_(double, CacheableDouble);

_GEODE_CACHEABLE_KEY_TYPE_DEF_(float, CacheableFloat, 63);
_GEODE_CACHEABLE_KEY_TYPE_DEF_(float, CacheableFloat);
/**
* An immutable wrapper for floats that can serve as
* a distributable key object for caching.
*/
_GEODE_CACHEABLE_KEY_TYPE_(float, CacheableFloat, 63);
_GEODE_CACHEABLE_KEY_TYPE_(float, CacheableFloat);

_GEODE_CACHEABLE_KEY_TYPE_DEF_(int16_t, CacheableInt16, 15);
_GEODE_CACHEABLE_KEY_TYPE_DEF_(int16_t, CacheableInt16);
/**
* An immutable wrapper for 16-bit integers that can serve as
* a distributable key object for caching.
*/
_GEODE_CACHEABLE_KEY_TYPE_(int16_t, CacheableInt16, 15);
_GEODE_CACHEABLE_KEY_TYPE_(int16_t, CacheableInt16);

_GEODE_CACHEABLE_KEY_TYPE_DEF_(int32_t, CacheableInt32, 15);
_GEODE_CACHEABLE_KEY_TYPE_DEF_(int32_t, CacheableInt32);
/**
* An immutable wrapper for 32-bit integers that can serve as
* a distributable key object for caching.
*/
_GEODE_CACHEABLE_KEY_TYPE_(int32_t, CacheableInt32, 15);
_GEODE_CACHEABLE_KEY_TYPE_(int32_t, CacheableInt32);

_GEODE_CACHEABLE_KEY_TYPE_DEF_(int64_t, CacheableInt64, 31);
_GEODE_CACHEABLE_KEY_TYPE_DEF_(int64_t, CacheableInt64);
/**
* An immutable wrapper for 64-bit integers that can serve as
* a distributable key object for caching.
*/
_GEODE_CACHEABLE_KEY_TYPE_(int64_t, CacheableInt64, 31);
_GEODE_CACHEABLE_KEY_TYPE_(int64_t, CacheableInt64);

_GEODE_CACHEABLE_KEY_TYPE_DEF_(char16_t, CacheableCharacter, 3);
_GEODE_CACHEABLE_KEY_TYPE_DEF_(char16_t, CacheableCharacter);
/**
* An immutable wrapper for characters that can serve as
* a distributable key object for caching.
*/
_GEODE_CACHEABLE_KEY_TYPE_(char16_t, CacheableCharacter, 3);
_GEODE_CACHEABLE_KEY_TYPE_(char16_t, CacheableCharacter);

// Instantiations for array built-in Cacheables

template <typename T, GeodeTypeIds::IdValues GeodeTypeId>
class _GEODE_EXPORT CacheableArray : public Cacheable {
class APACHE_GEODE_EXPORT CacheableArray : public Cacheable {
protected:
inline CacheableArray() = default;

Expand Down
2 changes: 1 addition & 1 deletion cppcache/include/geode/CacheableDate.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ namespace client {
* can serve as a distributable key object for caching as well as being a date
* value.
*/
class _GEODE_EXPORT CacheableDate : public CacheableKey {
class APACHE_GEODE_EXPORT CacheableDate : public CacheableKey {
private:
/**
* Milliseconds since January 1, 1970, 00:00:00 GMT to be consistent with Java
Expand Down
2 changes: 1 addition & 1 deletion cppcache/include/geode/CacheableEnum.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class DataInput;
class DataOutput;
class Serializable;

class _GEODE_EXPORT CacheableEnum : public CacheableKey {
class APACHE_GEODE_EXPORT CacheableEnum : public CacheableKey {
private:
std::string m_enumClassName;
std::string m_enumName;
Expand Down
2 changes: 1 addition & 1 deletion cppcache/include/geode/CacheableFileName.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class DataInput;
class DataOutput;
class Serializable;

class _GEODE_EXPORT CacheableFileName : public CacheableString {
class APACHE_GEODE_EXPORT CacheableFileName : public CacheableString {
public:
/**
*@brief serialize this object
Expand Down
2 changes: 1 addition & 1 deletion cppcache/include/geode/CacheableKey.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ namespace geode {
namespace client {

/** Represents a cacheable key */
class _GEODE_EXPORT CacheableKey : public Cacheable {
class APACHE_GEODE_EXPORT CacheableKey : public Cacheable {
protected:
/** Constructor */
CacheableKey() : Cacheable() {}
Expand Down
Loading

0 comments on commit 19165e2

Please sign in to comment.