Skip to content

Commit ced29ab

Browse files
authored
do not use cmake export all flag for windows
* do not use cmake export all flag for windows and try to export used symbols by hand * run examples in ci for windows
1 parent 0a5d300 commit ced29ab

22 files changed

+69
-43
lines changed

.github/workflows/ci.yaml

+12-19
Original file line numberDiff line numberDiff line change
@@ -53,26 +53,13 @@ jobs:
5353
shell: bash -l {0}
5454
run: |
5555
cd bld
56-
ctest -V
56+
ctest -V -R test
5757
58-
- name: Run examples
58+
- name: Run C++ examples
5959
shell: bash -l {0}
6060
run: |
61-
cd bld/examples/
62-
63-
pushd accumulator
64-
./main_accumulator .
65-
popd
66-
67-
pushd serialize
68-
./main_serialize .
69-
popd
70-
71-
pushd custom_factory_with_metadata
72-
./main_custom_factory_with_metadata .
73-
popd
74-
75-
61+
cd bld
62+
ctest -V -R example
7663
7764
- name: Install
7865
shell: bash -l {0}
@@ -123,7 +110,7 @@ jobs:
123110
-G Ninja ^
124111
-DCMAKE_BUILD_TYPE=Release ^
125112
-DXPLUGIN_BUILD_TESTS=ON ^
126-
-DXPLUGIN_BUILD_EXAMPLES=OFF ^
113+
-DXPLUGIN_BUILD_EXAMPLES=ON ^
127114
-DCMAKE_PREFIX_PATH="%CONDA_PREFIX%\Library" ^
128115
-DCMAKE_INSTALL_PREFIX="%CONDA_PREFIX%
129116
cmake --build . --config Release
@@ -132,7 +119,13 @@ jobs:
132119
shell: cmd /C CALL {0}
133120
run: |
134121
cd bld
135-
ctest -V --config Release
122+
ctest -V --config Release -R test
123+
124+
- name: Run C++ examples
125+
shell: cmd /C CALL {0}
126+
run: |
127+
cd bld
128+
ctest -V --config Release -R example
136129
137130
- name: Install
138131
shell: cmd /C CALL {0}

cmake/xplugin_add_xplugin.cmake

+1-2
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,8 @@ function(add_xplugin target_name)
55

66
if (WIN32)
77
# add compile definitions
8-
target_compile_definitions(${target_name} PUBLIC XPLUGIN_EXPORTS)
8+
target_compile_definitions(${target_name} PRIVATE XPLUGIN_EXPORTS)
99

10-
set_property(TARGET ${target_name} PROPERTY WINDOWS_EXPORT_ALL_SYMBOLS true)
1110
endif()
1211

1312
set_target_properties(${target_name} PROPERTIES

examples/accumulator/CMakeLists.txt

+6
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,9 @@ target_compile_features(main_accumulator PRIVATE cxx_std_17)
1515
set_target_properties(main_accumulator PROPERTIES POSITION_INDEPENDENT_CODE ON)
1616

1717
xplugin_add_emscripten_main_module_flags(main_accumulator)
18+
19+
20+
# if tests are enabled, add a the example to the tests
21+
if (XPLUGIN_BUILD_TESTS)
22+
add_test(NAME example_accumulator COMMAND main_accumulator ${CMAKE_CURRENT_BINARY_DIR})
23+
endif()

examples/accumulator/accumulator_base.hpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@
44
#include <string>
55
#include <vector>
66

7+
#include <xplugin/xplugin_config.hpp> // XPLUGIN_API
8+
79
namespace acc
810
{
9-
class AccumulatorBase
11+
class XPLUGIN_API AccumulatorBase
1012
{
1113
public:
1214
virtual ~AccumulatorBase()

examples/accumulator/plugin_accumulator_min.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
#include <algorithm>
55

6-
class AccumulatorMin : public acc::AccumulatorBase
6+
class XPLUGIN_API AccumulatorMin : public acc::AccumulatorBase
77
{
88
public:
99
AccumulatorMin() = default;

examples/custom_factory_with_metadata/CMakeLists.txt

+5
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,8 @@ target_link_libraries(main_custom_factory_with_metadata PUBLIC xplugin_host)
1111
set_target_properties(main_custom_factory_with_metadata PROPERTIES POSITION_INDEPENDENT_CODE ON)
1212

1313
xplugin_add_emscripten_main_module_flags(main_custom_factory_with_metadata)
14+
15+
# if tests are enabled, add a the example to the tests
16+
if (XPLUGIN_BUILD_TESTS)
17+
add_test(NAME example_custom_factory_with_metadata COMMAND main_custom_factory_with_metadata ${CMAKE_CURRENT_BINARY_DIR})
18+
endif()

examples/custom_factory_with_metadata/custom_factory_with_metadata_plugin_a.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// for XPLUGIN_CREATE_XPLUGIN_FACTORY macro
44
#include <xplugin/xfactory.hpp>
55

6-
class PluginA : public PluginBase
6+
class XPLUGIN_API PluginA : public PluginBase
77
{
88
public:
99
PluginA() = default;
@@ -19,7 +19,7 @@ class PluginA : public PluginBase
1919
std::string m_b;
2020
};
2121

22-
class PluginAFactory : public PluginFactoryBase
22+
class XPLUGIN_API PluginAFactory : public PluginFactoryBase
2323
{
2424
public:
2525
using factory_base_type = PluginFactoryBase;

examples/custom_factory_with_metadata/custom_factory_with_metadata_plugin_b.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// for XPLUGIN_CREATE_XPLUGIN_FACTORY macro
44
#include <xplugin/xfactory.hpp>
55

6-
class PluginB : public PluginBase
6+
class XPLUGIN_API PluginB : public PluginBase
77
{
88
public:
99
PluginB() = default;
@@ -19,7 +19,7 @@ class PluginB : public PluginBase
1919
std::string m_b;
2020
};
2121

22-
class PluginBFactory : public PluginFactoryBase
22+
class XPLUGIN_API PluginBFactory : public PluginFactoryBase
2323
{
2424
public:
2525
using factory_base_type = PluginFactoryBase;

examples/custom_factory_with_metadata/custom_factory_with_metadata_plugin_base.hpp

+4-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
#include <memory>
55
#include <string>
66

7-
class PluginBase
7+
#include <xplugin/xplugin_config.hpp>
8+
9+
class XPLUGIN_API PluginBase
810
{
911
public:
1012
virtual ~PluginBase()
@@ -14,7 +16,7 @@ class PluginBase
1416
virtual std::string some_function() const = 0;
1517
};
1618

17-
class PluginFactoryBase
19+
class XPLUGIN_API PluginFactoryBase
1820
{
1921
public:
2022
virtual ~PluginFactoryBase() = default;

examples/fubar/CMakeLists.txt

+5
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,8 @@ target_link_libraries(main_fubar PUBLIC xplugin_host)
1111
set_target_properties(main_fubar PROPERTIES POSITION_INDEPENDENT_CODE ON)
1212

1313
xplugin_add_emscripten_main_module_flags(main_fubar)
14+
15+
# if tests are enabled, add a the example to the tests
16+
if (XPLUGIN_BUILD_TESTS)
17+
add_test(NAME example_fubar COMMAND main_fubar ${CMAKE_CURRENT_BINARY_DIR})
18+
endif()

examples/fubar/fubar_base.hpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@
44
#include <string>
55
#include <vector>
66

7+
#include <xplugin/xplugin_config.hpp>
8+
79
namespace fubar
810
{
9-
class FubarBase
11+
class XPLUGIN_API FubarBase
1012
{
1113
public:
1214
virtual ~FubarBase()

examples/fubar/plugin_bar.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#include <fubar_base.hpp>
22
#include <xplugin/xfactory.hpp>
33

4-
class Bar : public fubar::FubarBase
4+
class XPLUGIN_API Bar : public fubar::FubarBase
55
{
66
public:
77
Bar(const std::string name)
@@ -19,5 +19,7 @@ class Bar : public fubar::FubarBase
1919
std::string name_;
2020
};
2121

22+
template class XPLUGIN_API xp::xfactory<Bar, fubar::FubarBase, const std::string &>;
23+
2224
using factory_type = xp::xfactory<Bar, fubar::FubarBase, const std::string &>;
2325
XPLUGIN_CREATE_XPLUGIN_FACTORY(factory_type);

examples/fubar/plugin_foo.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,7 @@ class Foo : public fubar::FubarBase
2020
std::string name_;
2121
};
2222

23+
template class XPLUGIN_API xp::xfactory<Foo, fubar::FubarBase, const std::string &>;
24+
2325
using factory_type = xp::xfactory<Foo, fubar::FubarBase, const std::string &>;
2426
XPLUGIN_CREATE_XPLUGIN_FACTORY(factory_type);

examples/serialize/serialize_base.hpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
#include <string>
55
#include <unordered_map>
66

7-
class SerializeBase
7+
#include <xplugin/xplugin_config.hpp>
8+
9+
class XPLUGIN_API SerializeBase
810
{
911
public:
1012
virtual ~SerializeBase() = default;

examples/serialize/serialize_json.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,7 @@ class SerializeJson : public SerializeBase
3636
}
3737
};
3838

39+
template class XPLUGIN_API xp::xfactory<SerializeJson, SerializeBase>;
40+
3941
using factory_type = xp::xfactory<SerializeJson, SerializeBase>;
4042
XPLUGIN_CREATE_XPLUGIN_FACTORY(factory_type);

examples/serialize/serialize_simple.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#include <sstream>
33
#include <xplugin/xfactory.hpp>
44

5-
class SerializeSimple : public SerializeBase
5+
class XPLUGIN_API SerializeSimple : public SerializeBase
66
{
77
public:
88
virtual ~SerializeSimple() = default;
@@ -36,5 +36,7 @@ class SerializeSimple : public SerializeBase
3636
}
3737
};
3838

39+
template class XPLUGIN_API xp::xfactory<SerializeSimple, SerializeBase>;
40+
3941
using factory_type = xp::xfactory<SerializeSimple, SerializeBase>;
4042
XPLUGIN_CREATE_XPLUGIN_FACTORY(factory_type);

include/xplugin/xfactory.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#include <memory>
1515

1616
#define XPLUGIN_CREATE_XPLUGIN_FACTORY(FACTORY_TYPE) \
17-
extern "C" XPLUGIN_EXPORT typename FACTORY_TYPE::factory_base_type *create_plugin_factory() \
17+
extern "C" XPLUGIN_API typename FACTORY_TYPE::factory_base_type *create_plugin_factory() \
1818
{ \
1919
return new FACTORY_TYPE(); \
2020
}

include/xplugin/xplugin_config.hpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,9 @@
1515
#else
1616
#define XPLUGIN_API __declspec(dllimport)
1717
#endif
18-
#define XPLUGIN_EXPORT __declspec(dllexport)
18+
1919
#else
2020
#define XPLUGIN_API
21-
#define XPLUGIN_EXPORT
2221
#endif
2322

2423
#define XPLUGIN_VERSION_MAJOR 0

test/testplugin_a/plugin_01.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
// the base factory for the plugin
55
#include <xplugin/xfactory.hpp>
66

7-
class Plugin01 : public plugin::PluginBase
7+
class XPLUGIN_API Plugin01 : public plugin::PluginBase
88
{
99
public:
1010
Plugin01(int a, std::string b)
@@ -22,5 +22,7 @@ class Plugin01 : public plugin::PluginBase
2222
std::string m_b;
2323
};
2424

25+
template class XPLUGIN_API xp::xfactory<Plugin01, plugin::PluginBase, int, std::string>;
26+
2527
using factory_type = xp::xfactory<Plugin01, plugin::PluginBase, int, std::string>;
2628
XPLUGIN_CREATE_XPLUGIN_FACTORY(factory_type);

test/testplugin_a/plugin_02.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
// the base factory for the plugin
55
#include <xplugin/xfactory.hpp>
66

7-
class Plugin02 : public plugin::PluginBase
7+
class XPLUGIN_API Plugin02 : public plugin::PluginBase
88
{
99
public:
1010
Plugin02(int a, std::string b)
@@ -22,5 +22,7 @@ class Plugin02 : public plugin::PluginBase
2222
std::string m_b;
2323
};
2424

25+
template class XPLUGIN_API xp::xfactory<Plugin02, plugin::PluginBase, int, std::string>;
26+
2527
using factory_type = xp::xfactory<Plugin02, plugin::PluginBase, int, std::string>;
2628
XPLUGIN_CREATE_XPLUGIN_FACTORY(factory_type);

test/testplugin_a/plugin_03.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
// the base factory for the plugin
55
#include <xplugin/xfactory.hpp>
66

7-
class Plugin03 : public plugin::PluginBase
7+
class XPLUGIN_API Plugin03 : public plugin::PluginBase
88
{
99
public:
1010
Plugin03(int a, std::string b)
@@ -22,5 +22,7 @@ class Plugin03 : public plugin::PluginBase
2222
std::string m_b;
2323
};
2424

25+
template class XPLUGIN_API xp::xfactory<Plugin03, plugin::PluginBase, int, std::string>;
26+
2527
using factory_type = xp::xfactory<Plugin03, plugin::PluginBase, int, std::string>;
2628
XPLUGIN_CREATE_XPLUGIN_FACTORY(factory_type);

test/testplugin_a/plugin_base.hpp

+1-4
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#include <string>
77
namespace plugin
88
{
9-
class PluginBase
9+
class XPLUGIN_API PluginBase
1010
{
1111
public:
1212
virtual ~PluginBase() = default;
@@ -17,9 +17,6 @@ class PluginBase
1717
};
1818
};
1919

20-
// all plugin instances expect to be constructed with the same arguments
21-
// in this case, an int and a string.
22-
using PluginFactoryBase = xp::xfactory_base<PluginBase, int, std::string>;
2320
}; // namespace plugin
2421

2522
#endif // PLUGIN_BASE_HPP

0 commit comments

Comments
 (0)