My problem is, that I have something like:
ace/
lib/
chaiscript/
spdlog/
libA/ --> uses chaiscript and spdlog
libB/ --> uses chaiscript and spdlog
src/
main.cpp --> uses libA and libB
CMakeLists.txt
How can I do this using cmake? In the case of other header-only libraries like spdlog, I simply write the following project file:
cmake_minimum_required(VERSION 3.1...3.11)
project(ace VERSION 5.0.0)
add_subdirectory(lib/spdlog/)
target_link_libraries(ace PRIVATE libA)
target_link_libraries(ace PRIVATE libB)
And inside the libraries I have:
cmake_minimum_required(VERSION 3.1...3.11)
project(libA VERSION 1.0.0)
target_link_libraries(libA PRIVATE spdlog)
@RubenReijers yes it does. But it was only added to the develop branch recently. You can do the following when
TerrainType
is an enum class:chaiscript::ModulePtr m = chaiscript::ModulePtr(new chaiscript::Module()); chaiscript::utility::add_class<TerrainType>(*m, "TerrainType", { { TerrainType::SOIL, "SOIL" }, {TerrainType::PASSABLE, "PASSABLE"}, { TerrainType::STONE, "STONE" } } );
Is it still possible to use enum classes this way in the current development branch?
auto key_module = std::make_shared<chaiscript::Module>();
chaiscript::utility::add_class<Key>(
*key_module, "Key",
{
{Key::N0, "KEY_N0"},
{Key::N1, "KEY_N1"},
{Key::N2, "KEY_N2"},
{Key::N3, "KEY_N3"},
{Key::N4, "KEY_N4"},
...
var k = Key();
print(k.KEY_N0);
terminate called after throwing an instance of 'chaiscript::exception::eval_error'
what(): Error: "Error with function dispatch for function 'to_string'" With parameters: (Key).()
var x = k.KEY_N0;
throws another error
Error: "'KEY_N0' is not a function."
chaiscript::exception::global_non_const If t_bv is not a constant object
Does it mean that t_bv should be const-qualified or just that I shouldn't ever modify it?
Moreover,
ChaiScript_Basic& chaiscript::ChaiScript_Basic::add_global_const ( const Boxed_Value & t_bv,
const std::string & t_name
)
it is const& in signature.
I am confused. Can someone elaborate?
I don't understand the distinction between the normal and the static-library versions of ChaiScript. I watched Jason's Intro To ChaiScript video, which showed him compiling normally in Linux, getting a library load error, then correcting the error by compiling using the static-lib constructor argument; but when I try a simple example using the normal version in Windows, it works correctly without the need to create any dynamically loaded library. Here's my sample code, which includes the main chaiscript header and adds no other chaiscript source code files:
...
auto hello = [](const std::string& aName)->std::string
{
return "Hello " + aName;
};
chaiscript::ChaiScript chai;
chai.add(chaiscript::fun(hello),"hello");
chai.eval("puts(hello(\"Graham\"))");
So I assume there's a difference between the way this library-loading system works under Windows and on other platforms. It would be great to have an explanation.