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

cmake source dir fixes #24

Open
wants to merge 6 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
67 changes: 34 additions & 33 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,47 +3,48 @@ project(generator)

list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")

include(GNUInstallDirs)

if(MSVC)
add_definitions(/W3)
else()
add_definitions(-std=c++11 -pedantic -Wall -Wextra)
endif()
add_subdirectory(src)
add_subdirectory(images)

set(LIBRARY_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/lib)
# include(GNUInstallDirs)

include_directories(${CMAKE_SOURCE_DIR}/include)
# if(MSVC)
# add_definitions(/W3)
# else()
# add_definitions(-std=c++11 -pedantic -Wall -Wextra)
# endif()

option(GENERATOR_USE_GLM "Use GLM instead of GML (experimental)" OFF)
if(GENERATOR_USE_GLM)
message(STATUS "Using GLM instead of GML for math (note the similar names). Support for this is experimental!")
add_definitions(-DGENERATOR_USE_GLM -DGLM_ENABLE_EXPERIMENTAL)
endif()
# set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/lib)

if(GENERATOR_USE_GLM)
option(GENERATOR_SUFFIX_GLM "Suffix library name with 'glm' when using GLM (otherwise, does nothing)" OFF)
set(GLM_INCLUDE_DIR "" CACHE FILEPATH "GLM include path")
# include_directories(${PROJECT_SOURCE_DIR}/include)

if(GENERATOR_SUFFIX_GLM AND GENERATOR_USE_GLM)
set(SUFFIX "-glm")
endif()
else()
set(GML_INCLUDE_DIR "" CACHE FILEPATH "GML include path")
endif()
# option(GENERATOR_USE_GLM "Use GLM instead of GML (experimental)" OFF)
# if(GENERATOR_USE_GLM)
# message(STATUS "Using GLM instead of GML for math (note the similar names). Support for this is experimental!")
# add_definitions(-DGENERATOR_USE_GLM -DGLM_ENABLE_EXPERIMENTAL)
# endif()

if(GML_INCLUDE_DIR AND NOT GENERATOR_USE_GLM)
include_directories(SYSTEM ${GML_INCLUDE_DIR})
elseif(GLM_INCLUDE_DIR AND GENERATOR_USE_GLM)
include_directories(SYSTEM ${GLM_INCLUDE_DIR})
endif()
# if(GENERATOR_USE_GLM)
# option(GENERATOR_SUFFIX_GLM "Suffix library name with 'glm' when using GLM (otherwise, does nothing)" OFF)
# set(GLM_INCLUDE_DIR "" CACHE FILEPATH "GLM include path")

set(TARGET_NAME ${CMAKE_STATIC_LIBRARY_PREFIX}generator${SUFFIX}${CMAKE_STATIC_LIBRARY_SUFFIX})
# if(GENERATOR_SUFFIX_GLM AND GENERATOR_USE_GLM)
# set(SUFFIX "-glm")
# endif()
# else()
# set(GML_INCLUDE_DIR "" CACHE FILEPATH "GML include path")
# endif()

message(STATUS "Target name is '${TARGET_NAME}'")
# if(GML_INCLUDE_DIR AND NOT GENERATOR_USE_GLM)
# include_directories(SYSTEM ${GML_INCLUDE_DIR})
# elseif(GLM_INCLUDE_DIR AND GENERATOR_USE_GLM)
# include_directories(SYSTEM ${GLM_INCLUDE_DIR})
# endif()

# set(TARGET_NAME ${CMAKE_STATIC_LIBRARY_PREFIX}generator${SUFFIX}${CMAKE_STATIC_LIBRARY_SUFFIX})
# message(STATUS "Target name is '${TARGET_NAME}'")

add_subdirectory(src)
add_subdirectory(images)

install(DIRECTORY include/generator DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
install(FILES lib/${TARGET_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR})
# install(DIRECTORY include/generator DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
# install(FILES lib/${TARGET_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR})
4 changes: 2 additions & 2 deletions images/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
add_executable(generate${SUFFIX} generate.cpp)
target_link_libraries(generate${SUFFIX} generator${SUFFIX})
add_executable(generate generate.cpp)
target_link_libraries(generate generator)
14 changes: 7 additions & 7 deletions include/generator/ExtrudeMesh.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@ namespace generator {
/// u-texture coordinate is taken from the shape and v from the path.
template <typename Shape, typename Path>
class ExtrudeMesh {
private:

Shape shape_;

Path path_;

int shapeVertexCount_;
public:

class Triangles {
Expand Down Expand Up @@ -155,13 +162,6 @@ class ExtrudeMesh {
shapeVertexCount_{count(shape_.vertices())}
{ }

private:

Shape shape_;

Path path_;

int shapeVertexCount_;

};

Expand Down
22 changes: 12 additions & 10 deletions include/generator/LatheMesh.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,18 @@ namespace generator {
/// the axis counterclockwise.
template <typename Shape>
class LatheMesh {

private:

gml::dvec3 axis_;

Shape shape_;

int slices_;

double start_;

double sweep_;
public:

class Triangles {
Expand Down Expand Up @@ -158,17 +170,7 @@ class LatheMesh {

Vertices vertices() const noexcept { return *this; }

private:

gml::dvec3 axis_;

Shape shape_;

int slices_;

double start_;

double sweep_;

};

Expand Down
9 changes: 5 additions & 4 deletions include/generator/SubdivideShape.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,15 @@ class SubdivideShape {
Edge generate() const {
Edge edge_ = edges_.generate();

assert(false && "revisit");
if (i_ % 2 == 0) return Edge{
edge_.vertices[0],
static_cast<int>(shape_->vertexCache_.size()) + i_ / 2
// edge_.vertices[0],
// static_cast<int>(shape_->vertexCache_.size()) + i_ / 2
};

return Edge{
static_cast<int>(shape_->vertexCache_.size()) + i_ / 2,
edge_.vertices[1]
// static_cast<int>(shape_->vertexCache_.size()) + i_ / 2,
// edge_.vertices[1]
};
}

Expand Down
6 changes: 4 additions & 2 deletions include/generator/utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@

namespace generator {


#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wnonnull"

/// Will have a type named "Type" that has same type as value returned by method
/// generate() of type Generator.
template <typename Generator>
Expand All @@ -20,7 +22,6 @@ class GeneratedType {

};


/// Will have a type named "Type" that has same type as value returned by method
/// edges() for type Primitive.
template <typename Primitive>
Expand Down Expand Up @@ -52,6 +53,7 @@ class VertexGeneratorType {
using Type = decltype(static_cast<const Primitive*>(nullptr)->vertices());

};
#pragma GCC diagnostic pop


/// Counts the number of steps left in the generator.
Expand Down
146 changes: 6 additions & 140 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,144 +1,10 @@
include_directories ("${CMAKE_SOURCE_DIR}/include")
file(GLOB_RECURSE GENERATOR_HEADERS *.hpp)
file(GLOB_RECURSE GENERATOR_SOURCES *.cpp )

set(GENERATOR_INCLUDE_DIR "${CMAKE_SOURCE_DIR}/include/generator")
add_library(generator STATIC ${GENERATOR_SOURCES} ${GENERATOR_HEADERS})

set(GENERATOR_HEADERS
${GENERATOR_INCLUDE_DIR}/AnyGenerator.hpp
${GENERATOR_INCLUDE_DIR}/AnyMesh.hpp
${GENERATOR_INCLUDE_DIR}/AnyPath.hpp
${GENERATOR_INCLUDE_DIR}/AnyShape.hpp
${GENERATOR_INCLUDE_DIR}/AxisFlipMesh.hpp
${GENERATOR_INCLUDE_DIR}/Axis.hpp
${GENERATOR_INCLUDE_DIR}/AxisSwapMesh.hpp
${GENERATOR_INCLUDE_DIR}/AxisSwapPath.hpp
${GENERATOR_INCLUDE_DIR}/AxisSwapShape.hpp
${GENERATOR_INCLUDE_DIR}/BezierMesh.hpp
${GENERATOR_INCLUDE_DIR}/BezierShape.hpp
${GENERATOR_INCLUDE_DIR}/BoxMesh.hpp
${GENERATOR_INCLUDE_DIR}/CappedConeMesh.hpp
${GENERATOR_INCLUDE_DIR}/CappedCylinderMesh.hpp
${GENERATOR_INCLUDE_DIR}/CappedTubeMesh.hpp
${GENERATOR_INCLUDE_DIR}/CapsuleMesh.hpp
${GENERATOR_INCLUDE_DIR}/CircleShape.hpp
${GENERATOR_INCLUDE_DIR}/ConeMesh.hpp
${GENERATOR_INCLUDE_DIR}/ConvexPolygonMesh.hpp
${GENERATOR_INCLUDE_DIR}/CylinderMesh.hpp
${GENERATOR_INCLUDE_DIR}/DiskMesh.hpp
${GENERATOR_INCLUDE_DIR}/DodecahedronMesh.hpp
${GENERATOR_INCLUDE_DIR}/Edge.hpp
${GENERATOR_INCLUDE_DIR}/EmptyMesh.hpp
${GENERATOR_INCLUDE_DIR}/EmptyPath.hpp
${GENERATOR_INCLUDE_DIR}/EmptyShape.hpp
${GENERATOR_INCLUDE_DIR}/ExtrudeMesh.hpp
${GENERATOR_INCLUDE_DIR}/FlipMesh.hpp
${GENERATOR_INCLUDE_DIR}/FlipPath.hpp
${GENERATOR_INCLUDE_DIR}/FlipShape.hpp
${GENERATOR_INCLUDE_DIR}/generator.hpp
${GENERATOR_INCLUDE_DIR}/GridShape.hpp
${GENERATOR_INCLUDE_DIR}/HelixPath.hpp
${GENERATOR_INCLUDE_DIR}/IcosahedronMesh.hpp
${GENERATOR_INCLUDE_DIR}/IcoSphereMesh.hpp
${GENERATOR_INCLUDE_DIR}/Iterator.hpp
${GENERATOR_INCLUDE_DIR}/KnotPath.hpp
${GENERATOR_INCLUDE_DIR}/LatheMesh.hpp
${GENERATOR_INCLUDE_DIR}/LinePath.hpp
${GENERATOR_INCLUDE_DIR}/LineShape.hpp
${GENERATOR_INCLUDE_DIR}/math.hpp
${GENERATOR_INCLUDE_DIR}/MergeMesh.hpp
${GENERATOR_INCLUDE_DIR}/MergePath.hpp
${GENERATOR_INCLUDE_DIR}/MergeShape.hpp
${GENERATOR_INCLUDE_DIR}/MeshVertex.hpp
${GENERATOR_INCLUDE_DIR}/MirrorMesh.hpp
${GENERATOR_INCLUDE_DIR}/ObjWriter.hpp
${GENERATOR_INCLUDE_DIR}/ParametricMesh.hpp
${GENERATOR_INCLUDE_DIR}/ParametricPath.hpp
${GENERATOR_INCLUDE_DIR}/ParametricShape.hpp
${GENERATOR_INCLUDE_DIR}/PathVertex.hpp
${GENERATOR_INCLUDE_DIR}/PlaneMesh.hpp
${GENERATOR_INCLUDE_DIR}/RectangleShape.hpp
${GENERATOR_INCLUDE_DIR}/RepeatMesh.hpp
${GENERATOR_INCLUDE_DIR}/RepeatPath.hpp
${GENERATOR_INCLUDE_DIR}/RepeatShape.hpp
${GENERATOR_INCLUDE_DIR}/RotateMesh.hpp
${GENERATOR_INCLUDE_DIR}/RotatePath.hpp
${GENERATOR_INCLUDE_DIR}/RotateShape.hpp
${GENERATOR_INCLUDE_DIR}/RoundedBoxMesh.hpp
${GENERATOR_INCLUDE_DIR}/RoundedRectangleShape.hpp
${GENERATOR_INCLUDE_DIR}/ScaleMesh.hpp
${GENERATOR_INCLUDE_DIR}/ScalePath.hpp
${GENERATOR_INCLUDE_DIR}/ScaleShape.hpp
${GENERATOR_INCLUDE_DIR}/ShapeToPath.hpp
${GENERATOR_INCLUDE_DIR}/ShapeVertex.hpp
${GENERATOR_INCLUDE_DIR}/SphereMesh.hpp
${GENERATOR_INCLUDE_DIR}/SphericalConeMesh.hpp
${GENERATOR_INCLUDE_DIR}/SphericalTriangleMesh.hpp
${GENERATOR_INCLUDE_DIR}/SpherifyMesh.hpp
${GENERATOR_INCLUDE_DIR}/SpringMesh.hpp
${GENERATOR_INCLUDE_DIR}/SubdivideMesh.hpp
${GENERATOR_INCLUDE_DIR}/SubdividePath.hpp
${GENERATOR_INCLUDE_DIR}/SubdivideShape.hpp
${GENERATOR_INCLUDE_DIR}/SvgWriter.hpp
${GENERATOR_INCLUDE_DIR}/TeapotMesh.hpp
${GENERATOR_INCLUDE_DIR}/TorusKnotMesh.hpp
${GENERATOR_INCLUDE_DIR}/TorusMesh.hpp
${GENERATOR_INCLUDE_DIR}/TransformMesh.hpp
${GENERATOR_INCLUDE_DIR}/TransformPath.hpp
${GENERATOR_INCLUDE_DIR}/TransformShape.hpp
${GENERATOR_INCLUDE_DIR}/TranslateMesh.hpp
${GENERATOR_INCLUDE_DIR}/TranslatePath.hpp
${GENERATOR_INCLUDE_DIR}/TranslateShape.hpp
${GENERATOR_INCLUDE_DIR}/Triangle.hpp
${GENERATOR_INCLUDE_DIR}/TriangleMesh.hpp
${GENERATOR_INCLUDE_DIR}/TubeMesh.hpp
${GENERATOR_INCLUDE_DIR}/utils.hpp
${GENERATOR_INCLUDE_DIR}/UvFlipMesh.hpp
${GENERATOR_INCLUDE_DIR}/UvSwapMesh.hpp
)
target_link_libraries(generator PUBLIC glm)

set(GENERATOR_SOURCES
AnyMesh.cpp
AnyPath.cpp
AnyShape.cpp
BoxMesh.cpp
CappedConeMesh.cpp
CappedCylinderMesh.cpp
CappedTubeMesh.cpp
CapsuleMesh.cpp
CircleShape.cpp
ConeMesh.cpp
ConvexPolygonMesh.cpp
CylinderMesh.cpp
DiskMesh.cpp
DodecahedronMesh.cpp
EmptyMesh.cpp
EmptyPath.cpp
EmptyShape.cpp
GridShape.cpp
HelixPath.cpp
IcosahedronMesh.cpp
IcoSphereMesh.cpp
KnotPath.cpp
LinePath.cpp
LineShape.cpp
ObjWriter.cpp
RectangleShape.cpp
SphereMesh.cpp
SphericalConeMesh.cpp
SphericalTriangleMesh.cpp
SpringMesh.cpp
SvgWriter.cpp
ParametricMesh.cpp
ParametricPath.cpp
ParametricShape.cpp
PlaneMesh.cpp
RoundedBoxMesh.cpp
RoundedRectangleShape.cpp
TeapotMesh.cpp
TorusKnotMesh.cpp
TorusMesh.cpp
TriangleMesh.cpp
TubeMesh.cpp
)

add_library(generator${SUFFIX} STATIC ${GENERATOR_SOURCES} ${GENERATOR_HEADERS})
target_include_directories(generator PUBLIC ${PROJECT_SOURCE_DIR}/include/)

target_compile_definitions(generator PUBLIC -DGENERATOR_USE_GLM -DGLM_ENABLE_EXPERIMENTAL)
1 change: 1 addition & 0 deletions src/GridShape.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "generator/GridShape.hpp"
#include <algorithm>

using namespace generator;

Expand Down