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

Introduce CMake #3

Open
wants to merge 13 commits into
base: master
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
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,9 @@
.DS_Store
/Build
/.idea/
/cmake-build-*/
/.vscode/
/.vs/
/out/
/build/

44 changes: 44 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
cmake_minimum_required(VERSION 3.14)
project(nima)

set(CMAKE_CXX_STANDARD 11)

option(NIMA_OPTION_BUILD_STATIC "Build static library, otherwise build shared" ON)

file(GLOB_RECURSE ALL_NIMA_SRC "Source/*.cpp")

if(NIMA_OPTION_BUILD_STATIC)
set(LIB_TYPE STATIC)
else()
set(LIB_TYPE SHARED)
endif()

add_subdirectory(Nima-Math-Cpp)

add_library(nima ${LIB_TYPE} ${ALL_NIMA_SRC})
target_include_directories(nima PUBLIC Source)
target_link_libraries(nima PRIVATE nima_math)

if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
add_compile_options(-Wall -Werror -g -std=c++11)
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
add_compile_options(/WX /W3)
add_compile_definitions(_CRT_SECURE_NO_WARNINGS)
endif()

install(
TARGETS nima
LIBRARY DESTINATION lib
)

install(
DIRECTORY Source/
DESTINATION include/nima
FILES_MATCHING PATTERN "*.hpp"
)

install(
DIRECTORY Nima-Math-Cpp/Source/
DESTINATION include/nima
FILES_MATCHING PATTERN "*.hpp"
)
57 changes: 0 additions & 57 deletions Makefile

This file was deleted.

2 changes: 1 addition & 1 deletion Nima-Math-Cpp
28 changes: 14 additions & 14 deletions Source/Actor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ void Actor::dispose()
{
delete [] m_Animations;

for (int i = 0; i < m_NestedActorAssetCount; i++)
for (unsigned int i = 0; i < m_NestedActorAssetCount; i++)
{
delete m_NestedActorAssets[i];
}
Expand Down Expand Up @@ -173,7 +173,7 @@ void Actor::eventCallback(ActorAnimationEvent::Callback callback, void* userdata

ActorAnimation* Actor::animation(const std::string& name) const
{
for (int i = 0; i < m_AnimationsCount; i++)
for (unsigned int i = 0; i < m_AnimationsCount; i++)
{
ActorAnimation& a = m_Animations[i];
if (a.name() == name)
Expand Down Expand Up @@ -274,7 +274,7 @@ void Actor::load(const std::string& filename)
load(bytes, (unsigned int)length);
delete [] bytes;
}
catch (OverflowException ex)
catch (const OverflowException &ex)
{
delete [] bytes;
throw ex;
Expand All @@ -287,7 +287,7 @@ void Actor::readNestedActorAssetsBlock(BlockReader* block)
m_NestedActorAssets = new NestedActorAsset*[m_NestedActorAssetCount];

BlockReader* nestedActorAssetBlock = nullptr;
int nestedActorIndex = 0;
unsigned int nestedActorIndex = 0;

while ((nestedActorAssetBlock = block->readNextBlock()) != nullptr)
{
Expand Down Expand Up @@ -316,7 +316,7 @@ void Actor::readAnimationsBlock(BlockReader* block)
m_Animations = new ActorAnimation[m_AnimationsCount];

BlockReader* animationBlock = nullptr;
int animationIndex = 0;
unsigned int animationIndex = 0;

while ((animationBlock = block->readNextBlock()) != nullptr)
{
Expand Down Expand Up @@ -604,7 +604,7 @@ void Actor::copy(const Actor& actor)
int ndeIdx = 0;
int nanIdx = 0;

for (int i = 0; i < m_ComponentCount; i++)
for (unsigned int i = 0; i < m_ComponentCount; i++)
{
ActorComponent* component = actor.m_Components[i];
if (component == nullptr)
Expand Down Expand Up @@ -639,7 +639,7 @@ void Actor::copy(const Actor& actor)

// Resolve indices.
m_Root = m_Nodes[0];
for (int i = 1; i < m_ComponentCount; i++)
for (unsigned int i = 1; i < m_ComponentCount; i++)
{
ActorComponent* component = m_Components[i];
if (component == nullptr)
Expand All @@ -651,7 +651,7 @@ void Actor::copy(const Actor& actor)

for (unsigned int i = 1; i < m_ComponentCount; i++)
{
ActorComponent* component = m_Components[i];
ActorComponent* component = m_Components[i];
if (component == nullptr)
{
continue;
Expand Down Expand Up @@ -703,7 +703,7 @@ bool Actor::addDirt(ActorComponent* component, unsigned char value, bool recurse
// so that the update loop can break out early and re-run (something up the tree is dirty).
if(component->m_GraphOrder < m_DirtDepth)
{
m_DirtDepth = component->m_GraphOrder;
m_DirtDepth = component->m_GraphOrder;
}

if(!recurse)
Expand All @@ -716,7 +716,7 @@ bool Actor::addDirt(ActorComponent* component, unsigned char value, bool recurse
{
addDirt(dependent, value, true);
}

return true;
}

Expand All @@ -726,15 +726,15 @@ void Actor::update()
{
const int maxSteps = 100;
int step = 0;
int count = m_DependencyOrder.size();
unsigned int count = m_DependencyOrder.size();
while((m_Flags & Flags::IsDirty) == Flags::IsDirty && step < maxSteps)
{
m_Flags &= ~Flags::IsDirty;
// Track dirt depth here so that if something else marks dirty, we restart.
for(int i = 0; i < count; i++)
for(unsigned int i = 0; i < count; i++)
{
ActorComponent* component = m_DependencyOrder[i];
m_DirtDepth = (unsigned int)i;
m_DirtDepth = i;
unsigned char d = component->m_DirtMask;
if(d == 0)
{
Expand Down Expand Up @@ -798,4 +798,4 @@ Actor* Actor::makeInstance() const
unsigned int Actor::componentCount() const
{
return m_ComponentCount;
}
}
6 changes: 4 additions & 2 deletions Source/ActorAxisConstraint.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@
#include "ActorTargetedConstraint.hpp"
#include "ActorBone.hpp"
#include "TransformSpace.hpp"
#include "nima/Mat2D.hpp"
#include "nima/TransformComponents.hpp"

#include <Mat2D.hpp>
#include <TransformComponents.hpp>

#include <vector>

namespace nima
Expand Down
3 changes: 2 additions & 1 deletion Source/ActorBoneBase.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
#define _NIMA_ACTORBONEBASE_HPP_

#include "ActorNode.hpp"
#include <nima/Vec2D.hpp>

#include <Vec2D.hpp>

namespace nima
{
Expand Down
5 changes: 3 additions & 2 deletions Source/ActorComponent.hpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
#ifndef _NIMA_ACTORCOMPONENT_HPP_
#define _NIMA_ACTORCOMPONENT_HPP_

#include <Mat2D.hpp>
#include <Vec2D.hpp>

#include <string>
#include <vector>
#include <nima/Mat2D.hpp>
#include <nima/Vec2D.hpp>

namespace nima
{
Expand Down
Loading