Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🎉 Added cmake buildsystem #1

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
Testbed/.vs
Testbed/x64
Testbed/Debug
Testbed/AS_DEBUG
conan*.txt
!conanfile.txt
conan.lock
graph_info.json
Find*.cmake
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ To install, just copy the 'RefCountingObject\*' files to your project.
Define your C++ classes by implementing `RefCountingObject`
and calling `RegisterRefCountingObject()` for each type.

```
```cpp
class Foo: RefCountingObject<Foo>{}
Foo::RegisterRefCountingObject("Foo", engine);
```
Expand All @@ -39,7 +39,7 @@ Define your C++ smart pointers by qualifying `RefCountingObjectPtr<>`
and use them in your interfaces.
These will become usable interchangeably from both C++ and script.

```
```cpp
typedef RefCountingObjectPtr<Foo> FooPtr;
// demo API:
static FooPtr gf;
Expand All @@ -59,7 +59,7 @@ engine->RegisterGlobalFunction("FooPtr@ GetFoo()", asFUNCTION(GetFoo), asCALL_CD

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

```
```cpp
FooPtr f1 = new Foo(); // refcount 1
SetFoo(f1); // refcount 2
FooPtr f2 = GetFoo(); // refcount 3
Expand Down
49 changes: 49 additions & 0 deletions Testbed/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#-------------------------------------------------------
# Testbed Main Build Script
#-------------------------------------------------------
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_BINARY_DIR})
cmake_minimum_required(VERSION 3.0)

set_property(GLOBAL PROPERTY USE_FOLDERS ON)


project(Testbed)

option(USE_CONAN "Use conan for installing deps" ON)

if (USE_CONAN)
if (NOT EXISTS "${CMAKE_BINARY_DIR}/conan.cmake")
message(STATUS "Downloading conan.cmake from https://github.com/conan-io/cmake-conan")
file(DOWNLOAD "https://raw.githubusercontent.com/conan-io/cmake-conan/0.18.1/conan.cmake" "${CMAKE_BINARY_DIR}/conan.cmake")
endif ()

include(${CMAKE_BINARY_DIR}/conan.cmake)
conan_cmake_configure(REQUIRES angelscript/2.35.1 GENERATORS cmake_find_package)
conan_cmake_autodetect(settings)
conan_cmake_install(PATH_OR_REFERENCE . BUILD missing SETTINGS ${settings})
endif ()

find_package(Angelscript REQUIRED)

set(CMAKE_CXX_STANDARD 11)

file(COPY "${CMAKE_SOURCE_DIR}/../Example.as" DESTINATION "${CMAKE_BINARY_DIR}")

set(SRC
../RefCountingObject.h
../RefCountingObjectPtr.h
debug_log.h
scriptstdstring.h

../Example.cpp
main.cpp
scriptstdstring.cpp
)

add_executable(${PROJECT_NAME} ${SRC})
target_compile_definitions(${PROJECT_NAME} PRIVATE RCO_ENABLE_DEBUGTRACE)
target_link_libraries(${PROJECT_NAME} PRIVATE Angelscript::angelscript)

if (WIN32)
target_link_libraries(${PROJECT_NAME} PRIVATE Winmm)
endif()
31 changes: 0 additions & 31 deletions Testbed/Testbed.sln

This file was deleted.

169 changes: 0 additions & 169 deletions Testbed/Testbed.vcxproj

This file was deleted.

38 changes: 0 additions & 38 deletions Testbed/Testbed.vcxproj.filters

This file was deleted.

4 changes: 0 additions & 4 deletions Testbed/Testbed.vcxproj.user

This file was deleted.

5 changes: 5 additions & 0 deletions Testbed/conanfile.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[requires]
angelscript/2.35.1

[generators]
cmake_find_package
2 changes: 1 addition & 1 deletion Testbed/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ int CompileScript(asIScriptEngine *engine)

// We will load the script from a file on the disk.
FILE *f = nullptr;
fopen_s(&f, "../Example.as", "rb");
fopen_s(&f, "Example.as", "rb");
if( f == 0 )
{
std::cout << "Failed to open the script file." << std::endl;
Expand Down