Build on Windows using Visual Studio and export symbols from DLL

This commit is contained in:
Gert Van Hoey 2017-07-04 21:41:17 +02:00
parent 0de3d164d7
commit 5bf860315e
2 changed files with 16 additions and 5 deletions

View File

@ -33,10 +33,13 @@ target_compile_features(json-schema-validator
cxx_range_for) # for C++11 - flags
target_compile_options(json-schema-validator
PUBLIC
-Wall -Wextra) # bad, better use something else based on compiler type
-Wall) # bad, better use something else based on compiler type
target_link_libraries(json-schema-validator
PUBLIC
json-hpp)
target_compile_definitions(json-schema-validator
PRIVATE
-DJSON_SCHEMA_VALIDATOR_EXPORTS)
# regex with boost if gcc < 4.8 - default is std::regex
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
@ -113,5 +116,3 @@ else()
message(STATUS "Consider setting JSON_SCHEMA_TEST_SUITE_PATH to a path in which JSON-Schema-Test-Suite is located (github.com/json-schema-org/JSON-Schema-Test-Suite).")
endif()

View File

@ -26,6 +26,16 @@
#ifndef NLOHMANN_JSON_SCHEMA_HPP__
#define NLOHMANN_JSON_SCHEMA_HPP__
#ifdef _WIN32
# ifdef JSON_SCHEMA_VALIDATOR_EXPORTS
# define JSON_SCHEMA_VALIDATOR_API __declspec(dllexport)
# else
# define JSON_SCHEMA_VALIDATOR_API __declspec(dllimport)
# endif
#else
# define JSON_SCHEMA_VALIDATOR_API
#endif
#include <json.hpp>
// make yourself a home - welcome to nlohmann's namespace
@ -83,7 +93,7 @@ public:
//
// This is done implement the requirements described in section 8.2.
//
class json_uri
class JSON_SCHEMA_VALIDATOR_API json_uri
{
std::string urn_;
@ -155,7 +165,7 @@ namespace json_schema_draft4
extern json draft4_schema_builtin;
class json_validator
class JSON_SCHEMA_VALIDATOR_API json_validator
{
std::vector<std::shared_ptr<json>> schema_store_;
std::shared_ptr<json> root_schema_;