Commit 3fc1d5a9 authored by Alexis Girault's avatar Alexis Girault

Merge branch 'correct-comp-linux' into 'master'

Correct comp linux

- Use CMake `CMAKE_CXX_STANDARD` to support C++11
- Check if `iMSTK_USE_OPENHAPTIC` is defined before using HDAPIDeviceClient in Sandbox
- Replace `itoa` (non standard) by `sprintf` in Sandbox
- Correct warnings in Sandbox

See merge request !90
parents 62fceea0 f16b6165
......@@ -69,6 +69,9 @@ mark_as_superbuild(
CMAKE_CXX_FLAGS
CMAKE_EXE_LINKER_FLAGS
CMAKE_SHARED_LINKER_FLAGS
CMAKE_CXX_STANDARD
CMAKE_CXX_STANDARD_REQUIRED
THREADS_PREFER_PTHREAD_FLAG
ALL_PROJECTS
)
......
......@@ -53,20 +53,9 @@ set(${PROJECT_NAME}_INSTALL_SHARE_DIR "${${PROJECT_NAME}_INSTALL_ROOT}/${${PROJE
#-----------------------------------------------------------------------------
# C++11 Support
#-----------------------------------------------------------------------------
include(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
if(COMPILER_SUPPORTS_CXX11)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -pthread" CACHE STRING "compile flags" FORCE)
elseif(COMPILER_SUPPORTS_CXX0X)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x -pthread" CACHE STRING "compile flags" FORCE)
else()
message(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.")
endif()
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++" CACHE STRING "compile flags" FORCE)
endif()
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(THREADS_PREFER_PTHREAD_FLAG ON)
#-----------------------------------------------------------------------------
# Define External dependencies
......
......@@ -448,6 +448,7 @@ void testTwoFalcons()
}
void testTwoOmnis(){
#ifdef iMSTK_USE_OPENHAPTICS
// SDK and Scene
auto sdk = std::make_shared<imstk::SimulationManager>();
auto scene = sdk->createNewScene("OmnisTestScene");
......@@ -493,6 +494,7 @@ void testTwoOmnis(){
// Run
sdk->setCurrentScene("OmnisTestScene");
sdk->startSimulation(false);
#endif
}
void testObjectController()
......@@ -1207,9 +1209,9 @@ void testPbdCloth()
// c. Add connectivity data
std::vector<imstk::SurfaceMesh::TriangleArray> triangles;
for (int i = 0; i < nRows - 1; i++)
for (std::size_t i = 0; i < nRows - 1; i++)
{
for (int j = 0; j < nCols - 1; j++)
for (std::size_t j = 0; j < nCols - 1; j++)
{
imstk::SurfaceMesh::TriangleArray tri[2];
tri[0] = { { i*nCols + j, (i + 1)*nCols + j, i*nCols + j + 1 } };
......@@ -1321,8 +1323,9 @@ void testPbdCollision()
int corner[4] = { 1, nRows, nRows*nCols - nCols + 1, nRows*nCols };
char intStr[33];
std::string fixed_corner;
for (unsigned int i = 0; i < 4; i++){
itoa(corner[i], intStr, 10);
for (unsigned int i = 0; i < 4; i++)
{
std::sprintf(intStr, "%d", corner[i]);
fixed_corner += std::string(intStr) + ' ';
}
vertList.resize(nRows*nCols);
......@@ -1343,9 +1346,9 @@ void testPbdCollision()
// c. Add connectivity data
std::vector<imstk::SurfaceMesh::TriangleArray> triangles;
for (int i = 0; i < nRows - 1; i++)
for (std::size_t i = 0; i < nRows - 1; i++)
{
for (int j = 0; j < nCols - 1; j++)
for (std::size_t j = 0; j < nCols - 1; j++)
{
imstk::SurfaceMesh::TriangleArray tri[2];
tri[0] = { { i*nCols + j, i*nCols + j + 1, (i + 1)*nCols + j } };
......@@ -1486,9 +1489,9 @@ void testPbdCollision()
// c. Add connectivity data
std::vector<imstk::SurfaceMesh::TriangleArray> triangles;
for (int i = 0; i < nRows - 1; i++)
for (std::size_t i = 0; i < nRows - 1; i++)
{
for (int j = 0; j < nCols - 1; j++)
for (std::size_t j = 0; j < nCols - 1; j++)
{
imstk::SurfaceMesh::TriangleArray tri[2];
tri[0] = { { i*nCols + j, i*nCols + j + 1, (i + 1)*nCols + j } };
......@@ -1545,7 +1548,9 @@ void testPbdCollision()
sdk->startSimulation(true);
}
void testLineMesh(){
void testLineMesh()
{
#ifdef iMSTK_USE_OPENHAPTICS
// SDK and Scene
auto sdk = std::make_shared<imstk::SimulationManager>();
auto scene = sdk->createNewScene("SceneTestMesh");
......@@ -1696,8 +1701,9 @@ void testLineMesh(){
int corner[4] = { 1, nRows, nRows*nCols - nCols + 1, nRows*nCols };
char intStr[33];
std::string fixed_corner;
for (unsigned int i = 0; i < 4; i++){
itoa(corner[i], intStr, 10);
for (unsigned int i = 0; i < 4; i++)
{
std::sprintf(intStr, "%d", corner[i]);
fixed_corner += std::string(intStr) + ' ';
}
vertList.resize(nRows*nCols);
......@@ -1870,4 +1876,5 @@ void testLineMesh(){
// Run
sdk->setCurrentScene("SceneTestMesh");
sdk->startSimulation(true);
}
\ No newline at end of file
#endif
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment