Skip to content

Commit 3e55b84

Browse files
committed
🎉 Added cmake buildsystem
1 parent b70dd77 commit 3e55b84

9 files changed

Lines changed: 76 additions & 250 deletions

File tree

.gitignore

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,18 @@
1-
Testbed/.vs
2-
Testbed/x64
3-
Testbed/Debug
4-
Testbed/AS_DEBUG
1+
CMakeFiles
2+
Solution/
3+
cmake_install.cmake
4+
Makefile
5+
CMakeCache.txt
6+
CPackConfig.cmake
7+
EnabledFeatures.txt
8+
CPackSourceConfig.cmake
9+
CMakeTmp
10+
build_x86
11+
build_x64
12+
dependencies/
13+
_build
14+
0_build
15+
build/
16+
.idea
17+
cmake-build-*/
18+
/.vs

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ To install, just copy the 'RefCountingObject\*' files to your project.
3030
Define your C++ classes by implementing `RefCountingObject`
3131
and calling `RegisterRefCountingObject()` for each type.
3232

33-
```
33+
```cpp
3434
class Foo: RefCountingObject<Foo>{}
3535
Foo::RegisterRefCountingObject("Foo", engine);
3636
```
@@ -39,7 +39,7 @@ Define your C++ smart pointers by qualifying `RefCountingObjectPtr<>`
3939
and use them in your interfaces.
4040
These will become usable interchangeably from both C++ and script.
4141
42-
```
42+
```cpp
4343
typedef RefCountingObjectPtr<Foo> FooPtr;
4444
// demo API:
4545
static FooPtr gf;
@@ -59,7 +59,7 @@ engine->RegisterGlobalFunction("FooPtr@ GetFoo()", asFUNCTION(GetFoo), asCALL_CD
5959

6060
In C++, use just the smart pointers and you'll be safe.
6161

62-
```
62+
```cpp
6363
FooPtr f1 = new Foo(); // refcount 1
6464
SetFoo(f1); // refcount 2
6565
FooPtr f2 = GetFoo(); // refcount 3

Testbed/CMakeLists.txt

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#-------------------------------------------------------
2+
# Testbed Main Build Script
3+
#-------------------------------------------------------
4+
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_BINARY_DIR})
5+
cmake_minimum_required(VERSION 3.0)
6+
7+
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
8+
9+
10+
project(Testbed)
11+
12+
option(USE_CONAN "Use conan for installing deps" ON)
13+
14+
if (USE_CONAN)
15+
if (NOT EXISTS "${CMAKE_BINARY_DIR}/conan.cmake")
16+
message(STATUS "Downloading conan.cmake from https://github.com/conan-io/cmake-conan")
17+
file(DOWNLOAD "https://raw.githubusercontent.com/conan-io/cmake-conan/0.18.1/conan.cmake" "${CMAKE_BINARY_DIR}/conan.cmake")
18+
endif ()
19+
20+
include(${CMAKE_BINARY_DIR}/conan.cmake)
21+
conan_cmake_configure(REQUIRES angelscript/2.35.1 GENERATORS cmake_find_package)
22+
conan_cmake_autodetect(settings)
23+
conan_cmake_install(PATH_OR_REFERENCE . BUILD missing SETTINGS ${settings})
24+
endif ()
25+
26+
find_package(Angelscript REQUIRED)
27+
28+
set(CMAKE_CXX_STANDARD 11)
29+
30+
file(COPY "${CMAKE_SOURCE_DIR}/../Example.as" DESTINATION "${CMAKE_BINARY_DIR}")
31+
32+
set(SRC
33+
../RefCountingObject.h
34+
../RefCountingObjectPtr.h
35+
debug_log.h
36+
scriptstdstring.h
37+
38+
../Example.cpp
39+
main.cpp
40+
scriptstdstring.cpp
41+
)
42+
43+
add_executable(${PROJECT_NAME} ${SRC})
44+
target_compile_definitions(${PROJECT_NAME} PRIVATE RCO_ENABLE_DEBUGTRACE)
45+
target_link_libraries(${PROJECT_NAME} PRIVATE Angelscript::angelscript)
46+
47+
if (WIN32)
48+
target_link_libraries(${PROJECT_NAME} PRIVATE Winmm)
49+
endif()

Testbed/Testbed.sln

Lines changed: 0 additions & 31 deletions
This file was deleted.

Testbed/Testbed.vcxproj

Lines changed: 0 additions & 169 deletions
This file was deleted.

Testbed/Testbed.vcxproj.filters

Lines changed: 0 additions & 38 deletions
This file was deleted.

Testbed/Testbed.vcxproj.user

Lines changed: 0 additions & 4 deletions
This file was deleted.

Testbed/conanfile.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[requires]
2+
angelscript/2.35.1
3+
4+
[generators]
5+
cmake_find_package

Testbed/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ int CompileScript(asIScriptEngine *engine)
244244

245245
// We will load the script from a file on the disk.
246246
FILE *f = nullptr;
247-
fopen_s(&f, "../Example.as", "rb");
247+
fopen_s(&f, "Example.as", "rb");
248248
if( f == 0 )
249249
{
250250
std::cout << "Failed to open the script file." << std::endl;

0 commit comments

Comments
 (0)