Advertisement

Integrating AngelScript into existing codebase (cmake)

Started by July 29, 2011 03:13 PM
9 comments, last by blubberbernd 13 years, 4 months ago
Hi,

what are the best ways of integrating AngelScript when using cmake? I tried this:
1) copy whole AS sdk into my project folder
2) in my own cmakelists I added "add_subdirectory(angelscript/angelscript/projects/cmake)"
3) further in my cmake file I added "target_link_libraries(Angelscript)"

But this doesn't work, it stops building on the first AS cpp file.

Can someone give me an advice on how is the best way to integratte AS into an existing cmake project?
Can't see why it shouldn't work.

What's the error?

Too many projects; too much time

Advertisement
If you want to compile AngelScript as part of your own application you can just include all the source files and header files into the project, and it should work without problems.

However, I recommend keeping AngelScript as a separate project and compile to a static library which you link with in your application.

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

Thanks for your replies.

Problem is that with a lib: every developer needs his own lib, depending on compiler and operating system (MingW, VC, Linux). This would make it hard to get unexpirenced new developers for the project because setting up the build envoironment is harder this way.
Setting up all source files in my cmake file was how I did it in first instance, but for some reason the AngelScript add ons did not work properly (I did set up the add on source files in my cmake file, too). The add ons were not found by the compiler. That's why I wanted to try the automatic lib building by calling your cmake file (after that I ended up posting here :D).

Personally I'm using MingW, but when I included the angelscript cmake file I got the strange error that "c:\MingW\msys\1.0\MP" could not be found when budling as_atomic.cpp. I'm not sure what this means, because this does obviously not exist, but I have no idea where I would have to look for the position in the cmake files (or whereever) to fix it (after all, I only called the angelscript cmake file from my cmake file, nothing more, nothing less).
You need to add the addons to your own project, not to the Angelscript project.

I do something like this in my project:

include_directories( ./include
// STUFF HERE
./addons/scriptstdstring
./addons/contextmgr
./addons/scriptany
./addons/scriptarray
./addons/scripthelper
./addons/scriptdictionary
)

set(HDRS
// STUFF HERE
./addons/scriptstdstring/scriptstdstring.h
./addons/contextmgr/contextmgr.h
./addons/scriptany/scriptany.h
./addons/scriptarray/scriptarray.h
./addons/scriptdictionary/scriptdictionary.h
./addons/scripthelper/scripthelper.h
)

set(SRCS
// STUFF HERE
./addons/scriptstdstring/scriptstdstring.cpp
./addons/contextmgr/contextmgr.cpp
./addons/scriptany/scriptany.cpp
./addons/scriptarray/scriptarray.cpp
./addons/scriptdictionary/scriptdictionary.cpp
./addons/scripthelper/scripthelper.cpp
)
add_executable(MyExecutable WIN32 ${HDRS} ${SRCS})

target_link_libraries(AngelscriptTest ${STUFF_HERE} angelscript)


In other words:
Add the addons to your own project.

Too many projects; too much time

Thanks. I think I'll do it also this way. It seems to work now (but I was not not changing the cmake file of AS, in the first place).

Not sure what I missed on the first try, maybe the include directories (seems I only added the .h files to the list, but not the folder).
Advertisement
I just found out what caused my problems. In the AngelScript cmake file at the bottom there is:


if(WIN32)
set_target_properties(Angelscript PROPERTIES COMPILE_FLAGS "/MP")
endif(WIN32)


I had to out-comment this. This was producing the error that "c:\MingW\msys\1.0\MP" is not found.
What needs to be changed in the cmake file in order to exclude this property just for MinGW?

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

You have different options.
if(MSVC)
if(MINGW)
if (CMAKE_COMPILER_IS_GNUCXX AND NOT MINGW)
if(WIN32 AND NOT MINGW)

Too many projects; too much time

Thanks. So by changing the cmake file to


if(WIN32 AND NOT MINGW)
set_target_properties(Angelscript PROPERTIES COMPILE_FLAGS "/MP")
endif(WIN32)


it will work?

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

This topic is closed to new replies.

Advertisement