Skip to content

Commit

Permalink
Merge pull request #77 from pyomeca/dev
Browse files Browse the repository at this point in the history
Release 1.1.1
  • Loading branch information
pariterre authored Sep 10, 2019
2 parents a068cf7 + 6619a12 commit 2c0cc2c
Show file tree
Hide file tree
Showing 31 changed files with 338 additions and 217 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ __pycache__

# Testing suite
Testing
test/c3dFiles/C3dTestSuite
test/c3dFiles/*
23 changes: 18 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ before_install:
bash miniconda.sh -b -p $HOME/miniconda;
elif [[ "$TRAVIS_OS_NAME" == "windows" ]]; then
choco install miniconda3 --params="'/AddToPath:1'";
export PATH="/c/tools/miniconda3/scripts:/c/tools/miniconda3/:$PATH";
export PATH="/c/tools/miniconda3/scripts:/c/tools/miniconda3/:/c/Program Files/Git/miniconda3/bin/:$PATH";
fi
- export PATH="$HOME/miniconda/bin:$PATH"
- hash -r
Expand Down Expand Up @@ -59,20 +59,33 @@ script:
cmake ${CMAKE_OPTIONS} -DCMAKE_INSTALL_PREFIX= -DCMAKE_CXX_FLAGS=${CXX_FLAGS} -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTS=ON -DBUILD_DOC=OFF -DBUILD_EXAMPLE=OFF .. ;
make;
elif [[ "$TRAVIS_OS_NAME" == "windows" ]]; then
cmake -G"Visual Studio 15 2017 Win64" -DCMAKE_INSTALL_PREFIX= -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTS=ON -DBUILD_DOC=OFF -DBUILD_EXAMPLE=OFF ..;
cmake -G"Visual Studio 15 2017 Win64" -DCMAKE_INSTALL_PREFIX=$ToolsDir/miniconda3/ -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTS=ON -DBUILD_DOC=OFF -DBUILD_EXAMPLE=OFF ..;
cmake --build ./ --config Release;
fi
# Only do the coverage on Linux, but run the test anyway to get a nice output
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then
cp -r test/c3dTestFiles/ .;
elif [[ "$TRAVIS_OS_NAME" == "osx" ]]; then
cd test;
elif [[ "$TRAVIS_OS_NAME" == "windows" ]]; then
cp bin/Release/*.dll ./test/Release;
cp Release/*.dll ./test/Release;
cd test\\Release;
mkdir .\\c3dTestFiles;
xcopy ..\\c3dTestFiles .\\c3dTestFiles;
fi
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then
make ezc3d_coverage;
elif [[ "$TRAVIS_OS_NAME" == "osx" ]]; then
./runUnitTests;
elif [[ "$TRAVIS_OS_NAME" == "windows" ]]; then
cp bin/Release/*.dll .;
cp Release/*.dll .;
cp Release/*.exe .;
./runUnitTests.exe;
fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then
cd ..;
elif [[ "$TRAVIS_OS_NAME" == "windows" ]]; then
cd ../..;
fi
- ctest
- if [[ "$TRAVIS_OS_NAME" != "windows" ]]; then
cmake ${CMAKE_OPTIONS} -DCMAKE_INSTALL_PREFIX=$HOME/miniconda/ -DCMAKE_CXX_FLAGS=${CXX_FLAGS} -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTS=OFF -DBUILD_DOC=OFF -DBUILD_EXAMPLE=OFF -DBINDER_PYTHON3=ON ..;
Expand Down
144 changes: 20 additions & 124 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.8)
cmake_policy(SET CMP0048 NEW)
project(ezc3d VERSION 1.1.0)
project(ezc3d VERSION 1.1.1)
set(CMAKE_CXX_STANDARD 11)

# Set some variables
Expand All @@ -27,7 +27,7 @@ set_target_properties(${PROJECT_NAME} PROPERTIES DEBUG_POSTFIX "_debug")
# Add headers
target_include_directories(${PROJECT_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include)

# Installation
# Install target
if(WIN32)
set(${PROJECT_NAME}_LIB_FOLDER Lib)
set(${PROJECT_NAME}_BIN_FOLDER bin)
Expand All @@ -43,141 +43,37 @@ install(TARGETS ${PROJECT_NAME}
LIBRARY DESTINATION ${${PROJECT_NAME}_LIB_FOLDER}
)
install(DIRECTORY include DESTINATION ${${PROJECT_NAME}_INCLUDE_FOLDER})

# Add binding subdirectory

# uninstall target
if(NOT TARGET uninstall)
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
IMMEDIATE @ONLY)

add_custom_target(uninstall
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)
endif()

# Binders
add_subdirectory(binding)

# Add the example if asked
# Examples
if(NOT WIN32)
set(BUILD_EXAMPLE TRUE CACHE BOOL "Build a C++ example")
option(BUILD_EXAMPLE "Build a C++ example" ON)
if (BUILD_EXAMPLE)
add_subdirectory(example)
endif()
endif(NOT WIN32)


################################
# Documentation
################################

# first we can indicate the documentation build as an option and set it to ON by default
# Doc
option(BUILD_DOC "Build documentation" OFF)

if (BUILD_DOC)
# check if Doxygen is installed
find_package(Doxygen)
if (DOXYGEN_FOUND)
# set input and output files
set(DOXYGEN_IN ${CMAKE_CURRENT_SOURCE_DIR}/docs/Doxyfile.in)
set(DOXYGEN_OUT ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile)

# request to configure the file
configure_file(${DOXYGEN_IN} ${DOXYGEN_OUT} @ONLY)

# note the option ALL which allows to build the docs together with the application
add_custom_target( doc_doxygen ALL
COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYGEN_OUT}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMENT "Generating API documentation with Doxygen"
VERBATIM )
else (DOXYGEN_FOUND)
message("Doxygen need to be installed to generate the doxygen documentation")
endif (DOXYGEN_FOUND)
add_subdirectory(docs)
endif (BUILD_DOC)


################################
# Testing
################################

# Options. Turn on with 'cmake -DBUILD_TESTS=ON'.
option(BUILD_TESTS "Build all tests." OFF) # Makes boolean 'test' available.

if (BUILD_TESTS)
# Download gtest if necessary
set(RELATIVE_PATH_TO_GTEST external/gtest)
find_path(GTEST_INCLUDE_DIR gtest.h HINTS ${CMAKE_CURRENT_SOURCE_DIR}/${RELATIVE_PATH_TO_GTEST}/googletest/include/gtest)

if((NOT GTEST_INCLUDE_DIR) OR (NOT EXISTS ${GTEST_INCLUDE_DIR}))
# we couldn't find the header files for gtest or they don't exist
message("Unable to find gtest")

# we have a submodule setup for gtest, assume it is under external/gtest
# now we need to clone this submodule
execute_process(COMMAND git submodule update --init -- external/gtest
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})

find_path(GTEST_INCLUDE_DIR gtest.h HINTS ${CMAKE_CURRENT_SOURCE_DIR}/${RELATIVE_PATH_TO_GTEST}/googletest/include/gtest)
endif()

# Prevent overriding the parent project's compiler/linker
# settings on Windows
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)

# Add googletest directly to our build. This defines
# the gtest and gtest_main targets.
set(BUILD_GMOCK OFF)
set(INSTALL_GTEST OFF)
add_subdirectory(${RELATIVE_PATH_TO_GTEST}
${CMAKE_BINARY_DIR}/gtest
EXCLUDE_FROM_ALL)

##############
# Unit Tests
##############
enable_testing()

file(GLOB TEST_SRC_FILES ${CMAKE_CURRENT_SOURCE_DIR}/test/*.cpp)
add_executable(runUnitTests ${TEST_SRC_FILES})

# Standard linking to gtest stuff.
target_link_libraries(runUnitTests gtest_main)

# Extra linking for the project.
target_link_libraries(runUnitTests ${PROJECT_NAME})

# This is so you can do 'make test' to see all your tests run, instead of
# manually running the executable runUnitTests to see those specific tests.
add_test(UnitTests runUnitTests)

if (CMAKE_BUILD_TYPE STREQUAL "Coverage")
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/.travis/cmake)

include(CodeCoverage)
setup_target_for_coverage(${PROJECT_NAME}_coverage runUnitTests coverage)

SET(CMAKE_CXX_FLAGS "-g -O0 -fprofile-arcs -ftest-coverage")
SET(CMAKE_C_FLAGS "-g -O0 -fprofile-arcs -ftest-coverage")
endif() #CMAKE_BUILD_TYPE STREQUAL "Coverage"

# Download and copy c3d test files from test test suite of c3d.org and add them to the local test files
IF(NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/test/c3dFiles/C3dTestSuite)
set(TEST_FILES_TO_DOWNLOAD Sample01.zip Sample02.zip)
foreach(FILE ${TEST_FILES_TO_DOWNLOAD})
file(
DOWNLOAD https://www.c3d.org/data/${FILE}
${CMAKE_CURRENT_SOURCE_DIR}/test/c3dFiles/C3dTestSuite/${FILE}
TIMEOUT 60 # seconds
TLS_VERIFY ON
)
get_filename_component(FOLDER_NAME ${FILE} NAME_WE)
file(MAKE_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/test/c3dFiles/C3dTestSuite/${FOLDER_NAME})
execute_process(
COMMAND ${CMAKE_COMMAND} -E tar -xf ../${FILE}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/test/c3dFiles/C3dTestSuite/${FOLDER_NAME}/
)
file(GLOB C3D_TEST_FILES ${CMAKE_CURRENT_SOURCE_DIR}/test/c3dFiles/C3dTestSuite/${FOLDER_NAME}/*.c3d)
file(COPY ${C3D_TEST_FILES}
DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/c3dTestFiles/)
endforeach()
endif()

# Copy also some local c3d test files
file(GLOB C3D_TEST_FILES ${CMAKE_CURRENT_SOURCE_DIR}/test/c3dFiles/*.c3d)
file(COPY ${C3D_TEST_FILES}
DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/c3dTestFiles/)
add_subdirectory(test)
endif()




28 changes: 20 additions & 8 deletions binding/python3/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
# Include python
find_package(PYTHON3 REQUIRED)
include_directories(${Python3_INCLUDE_DIRS})

find_package(Numpy REQUIRED)

include_directories(${NUMPY_INCLUDES})
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../include)
if(WIN32)
link_directories(${Python3_RUNTIME_LIBRARY_DIRS}/libs)
link_directories(${Python3_RUNTIME_LIBRARY_DIRS}/libs)
endif()
if (APPLE)
# For unknown reason the later set properties over SWIG_INCLUDE_DIRECTORIES doesn't work
# on travis
include_directories(${CMAKE_SOURCE_DIR}/include)
endif ()

# Add swig module
set(CMAKE_SWIG_FLAGS "")
Expand All @@ -17,22 +22,28 @@ set_property(SOURCE ${I_SOURCE_FILE} PROPERTY CPLUSPLUS ON)
SWIG_ADD_LIBRARY(${PROJECT_NAME} TYPE MODULE LANGUAGE python SOURCES ${I_SOURCE_FILE})
swig_link_libraries(${PROJECT_NAME} ${PROJECT_NAME} ${PYTHON_LIBRARIES} ${NUMPY_LIBRARIES})

# Add headers
target_include_directories(_${PROJECT_NAME} PUBLIC
${CMAKE_SOURCE_DIR}/include
)
set_target_properties(_${PROJECT_NAME} PROPERTIES SWIG_INCLUDE_DIRECTORIES ${CMAKE_SOURCE_DIR}/include)

if(APPLE)
SET_TARGET_PROPERTIES(_${PROJECT_NAME} PROPERTIES SUFFIX ".so" INSTALL_RPATH ${${PROJECT_NAME}_BIN_FOLDER})
SET_TARGET_PROPERTIES(_${PROJECT_NAME} PROPERTIES INSTALL_RPATH_USE_LINK_PATH TRUE)
set_property(TARGET _${PROJECT_NAME} APPEND PROPERTY LINK_FLAGS "-flat_namespace -undefined suppress")
else()
SET_TARGET_PROPERTIES(_${PROJECT_NAME} PROPERTIES INSTALL_RPATH ${${PROJECT_NAME}_BIN_FOLDER})
SET_TARGET_PROPERTIES(_${PROJECT_NAME} PROPERTIES INSTALL_RPATH_USE_LINK_PATH TRUE)
endif()

SET_TARGET_PROPERTIES(_${PROJECT_NAME} PROPERTIES INSTALL_RPATH_USE_LINK_PATH TRUE)

# Install to the proper directories
INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.py
DESTINATION ${Python3_SITELIB}/${PROJECT_NAME})
DESTINATION ${Python3_SITELIB}/${PROJECT_NAME}
)

INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/__init__.py
DESTINATION ${Python3_SITELIB}/${PROJECT_NAME})
DESTINATION ${Python3_SITELIB}/${PROJECT_NAME}
)

# Check if swig has its version 3 or 4, to choose the right place to put the library
if(${SWIG_VERSION} MATCHES "^3(\.[0-9]*)*$")
Expand All @@ -45,5 +56,6 @@ endif()

# Install the library
INSTALL(TARGETS _${PROJECT_NAME}
DESTINATION ${PYTHON_INSTALL_DESTINATION})
DESTINATION ${PYTHON_INSTALL_DESTINATION}
)

22 changes: 22 additions & 0 deletions cmake_uninstall.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
if(NOT EXISTS "@CMAKE_BINARY_DIR@/install_manifest.txt")
message(FATAL_ERROR "Cannot find install manifest: @CMAKE_BINARY_DIR@/install_manifest.txt")
endif(NOT EXISTS "@CMAKE_BINARY_DIR@/install_manifest.txt")

file(READ "@CMAKE_BINARY_DIR@/install_manifest.txt" files)
string(REGEX REPLACE "\n" ";" files "${files}")
foreach(file ${files})
message(STATUS "Uninstalling $ENV{DESTDIR}${file}")
if(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
exec_program(
"@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\""
OUTPUT_VARIABLE rm_out
RETURN_VALUE rm_retval
)
if(NOT "${rm_retval}" STREQUAL 0)
message(FATAL_ERROR "Problem when removing $ENV{DESTDIR}${file}")
endif(NOT "${rm_retval}" STREQUAL 0)
else(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
message(STATUS "File $ENV{DESTDIR}${file} does not exist.")
endif(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
endforeach(file)

18 changes: 18 additions & 0 deletions docs/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
set(MASTER_PROJECT_NAME ${PROJECT_NAME})
project(${MASTER_PROJECT_NAME}_docs)

# check if Doxygen is installed
find_package(Doxygen REQUIRED)
# set input and output files
set(DOXYGEN_IN ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in)
set(DOXYGEN_OUT ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile)

# request to configure the file
configure_file(${DOXYGEN_IN} ${DOXYGEN_OUT} @ONLY)

# note the option ALL which allows to build the docs together with the application
add_custom_target( doc_doxygen ALL
COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYGEN_OUT}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMENT "Generating API documentation with Doxygen"
VERBATIM )
10 changes: 5 additions & 5 deletions docs/Doxyfile.in
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
OUTPUT_DIRECTORY = @CMAKE_CURRENT_BINARY_DIR@/docs/
INPUT += @CMAKE_CURRENT_SOURCE_DIR@/include/
INPUT += @CMAKE_CURRENT_SOURCE_DIR@/src/
INPUT += @CMAKE_CURRENT_SOURCE_DIR@/docs
OUTPUT_DIRECTORY = @CMAKE_CURRENT_BINARY_DIR@/
INPUT += @CMAKE_SOURCE_DIR@/include/
INPUT += @CMAKE_SOURCE_DIR@/src/
INPUT += @CMAKE_SOURCE_DIR@/docs

# Remove dll_export that confuses Doxygen
ENABLE_PREPROCESSING = YES
Expand All @@ -15,4 +15,4 @@ FULL_PATH_NAMES = NO
SOURCE_BROWSER = YES

# Add the Readme file
INPUT += @CMAKE_CURRENT_SOURCE_DIR@/README.md
INPUT += @CMAKE_SOURCE_DIR@/README.md
4 changes: 2 additions & 2 deletions example/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ int main()
ezc3d::DataNS::AnalogsNS::Channel c(subframes_analog.channel(0));
c.data(sf + 1);
subframes_analog.channel(c, 0);
frame.analogs_nonConst().subframe(subframes_analog);
frame.analogs().subframe(subframes_analog);
}
for (size_t f = 0; f < c3d.data().nbFrames(); ++f)
frames_analog.push_back(frame);
Expand Down Expand Up @@ -189,7 +189,7 @@ int main()
newChannel.data(sf+1);
ezc3d::DataNS::AnalogsNS::SubFrame subframes_analog;
subframes_analog.channel(newChannel);
frame.analogs_nonConst().subframe(subframes_analog);
frame.analogs().subframe(subframes_analog);
}
for (size_t f=0; f<c3d.data().nbFrames(); ++f)
frames_analog.push_back(frame);
Expand Down
2 changes: 1 addition & 1 deletion include/Analogs.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ class EZC3D_API ezc3d::DataNS::AnalogsNS::Analogs{
///
/// Throw a std::out_of_range exception if idx is larger than the number of subframes
///
ezc3d::DataNS::AnalogsNS::SubFrame& subframe_nonConst(size_t idx);
ezc3d::DataNS::AnalogsNS::SubFrame& subframe(size_t idx);

///
/// \brief Add/replace a subframe to the analogous data set
Expand Down
2 changes: 1 addition & 1 deletion include/Data.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class EZC3D_API ezc3d::DataNS::Data{
/// Throw a std::out_of_range exception if idx is larger than the number of frames
///
///
ezc3d::DataNS::Frame& frame_nonConst(size_t idx);
ezc3d::DataNS::Frame& frame(size_t idx);

///
/// \brief Add/replace a frame to the data set
Expand Down
Loading

0 comments on commit 2c0cc2c

Please sign in to comment.