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

Fix various build issues with Visual Studio 2017 (15.5.3) #956

Merged
merged 7 commits into from
Jan 12, 2018
Merged
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
78 changes: 78 additions & 0 deletions .appveyor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# Specify version format
version: "{build}"

image: Visual Studio 2017

platform: x64

# specify custom environment variables
environment:
MSVC_DEFAULT_OPTIONS: ON
CMAKE_TOOLCHAIN_FILE: -DCMAKE_TOOLCHAIN_FILE="C:\tools\vcpkg\scripts\buildsystems\vcpkg.cmake"
matrix:
- CMAKE_GENERATOR: -G"Visual Studio 15 2017 Win64"
CMAKE_TOOLCHAIN: -T"v141"

# build configuration, i.e. Debug, Release, etc.
configuration:
- Debug
- Release

# scripts that are called at very beginning, before repo cloning
init:
- cmd: cmake --version
- cmd: msbuild /version

# clone directory
clone_folder: C:\projects\dart

# branches to build
branches:
# blacklist
except:
- gh-pages

# scripts that run after cloning repository
install:
- if "%platform%"=="Win32" set VCPKG_ARCH=x86-windows
- if "%platform%"=="x64" set VCPKG_ARCH=x64-windows

# install pacakges
# ---- required dependencies: boost, eigen3, libccd, fcl, assimp
- vcpkg install boost:%VCPKG_ARCH%
- vcpkg install eigen3:%VCPKG_ARCH%
- vcpkg install ccd:%VCPKG_ARCH%
- vcpkg install fcl:%VCPKG_ARCH%
- vcpkg install assimp:%VCPKG_ARCH%
# ---- optional dependencies: nlopt, ipopt, bullet3, ode, flann, tinyxml2, urdfdom_headers, urdfdom, opengl, freeglut, osg
#- vcpkg install nlopt:%VCPKG_ARCH%
#- vcpkg install ipopt:%VCPKG_ARCH%
#- vcpkg install bullet3:%VCPKG_ARCH%
#- vcpkg install ode:%VCPKG_ARCH%
#- vcpkg install flann:%VCPKG_ARCH%
#- vcpkg install tinyxml2:%VCPKG_ARCH%
#- vcpkg install urdfdom-headers:%VCPKG_ARCH%
#- vcpkg install urdfdom:%VCPKG_ARCH%
#- vcpkg install opengl:%VCPKG_ARCH%
#- vcpkg install freeglut:%VCPKG_ARCH%
#- vcpkg install osg:%VCPKG_ARCH%

- vcpkg integrate install

- cmd: cd C:\projects\dart
- cmd: md build
- cmd: cd build
- cmd: cmake %CMAKE_GENERATOR% -DCMAKE_BUILD_TYPE=%configuration% -DDART_MSVC_DEFAULT_OPTIONS="%MSVC_DEFAULT_OPTIONS%" %CMAKE_TOOLCHAIN_FILE% %CMAKE_TOOLCHAIN% ..

# preserve contents of selected directories and files across project builds
cache:
- C:\tools\vcpkg\installed -> .appveyor.yml
- C:\tools\vcpkg\packages -> .appveyor.yml

build:
project: C:\projects\dart\build\dart.sln # path to Visual Studio solution or project
parallel: true # enable MSBuild parallel builds
verbosity: quiet # MSBuild verbosity level (quiet|minimal|normal|detailed)

#test_script:
#- cmd: ctest --build-config %configuration% --parallel 4 --output-on-failure
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
* Misc

* Suppressed warnings: [#937](https://github.com/dartsim/dart/pull/937)
* Fixed various build issues with Visual Studio: [#956](https://github.com/dartsim/dart/pull/956)

### [DART 6.3.0 (2017-10-04)](https://github.com/dartsim/dart/milestone/36?closed=1)

Expand Down
18 changes: 14 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#===============================================================================
# CMake 2.8.12 or above is required for CMakeParseArguments.
if(MSVC)
cmake_minimum_required(VERSION 3.1.3)
cmake_minimum_required(VERSION 3.8.0)
else()
cmake_minimum_required(VERSION 2.8.12)
endif()
Expand Down Expand Up @@ -159,17 +159,27 @@ if(MSVC)

# Visual Studio enables c++11 support by default
if(MSVC_VERSION VERSION_LESS 1900)
message(FATAL_ERROR "${PROJECT_NAME} requires VS 2015 or greater.")
message(FATAL_ERROR "${PROJECT_NAME} requires VS2017 or greater.")
endif()
if(DART_TREAT_WARNINGS_AS_ERRORS)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /WX")
endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP4")
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "/LTCG /INCREMENTAL:NO")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc /permissive-")
#set(CMAKE_EXE_LINKER_FLAGS_RELEASE "/LTCG /INCREMENTAL:NO")
if(NOT DART_MSVC_DEFAULT_OPTIONS)
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${DART_RUNTIME_LIBRARY}d /Zi /Gy /W1 /EHsc")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${DART_RUNTIME_LIBRARY} /Zi /GL /Gy /W1 /EHsc")
endif(NOT DART_MSVC_DEFAULT_OPTIONS)
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
add_compile_options(/wd4334)
add_compile_options(/wd4267)
add_compile_options(/wd4244)
add_compile_options(/wd4250)
add_compile_options(/wd4996)
add_compile_options(/wd4099)
add_compile_options(/wd4305)
add_compile_options(/wd4838)
add_compile_options(/bigobj)

elseif(CMAKE_COMPILER_IS_GNUCXX)

Expand Down
63 changes: 0 additions & 63 deletions appveyor.yml

This file was deleted.

2 changes: 1 addition & 1 deletion cmake/FindFCL.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ find_package(PkgConfig QUIET)
pkg_check_modules(PC_FCL fcl QUIET)

# Include directories
if (${PC_FCL_VERSION} VERSION_LESS 0.6.0)
if(PC_FCL_VERSION VERSION_LESS 0.6.0)
find_path(FCL_INCLUDE_DIRS
NAMES fcl/collision.h
HINTS ${PC_FCL_INCLUDEDIR}
Expand Down
13 changes: 10 additions & 3 deletions dart/collision/CollisionDetector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,13 @@ CollisionDetector::CollisionObjectManager::CollisionObjectManager(
assert(cd);
}

//==============================================================================
CollisionDetector*
CollisionDetector::CollisionObjectManager::getCollisionDetector()
{
return mCollisionDetector;
}

//==============================================================================
CollisionDetector::
ManagerForUnsharableCollisionObjects::ManagerForUnsharableCollisionObjects(
Expand Down Expand Up @@ -117,7 +124,7 @@ void
CollisionDetector::ManagerForUnsharableCollisionObjects
::CollisionObjectDeleter::operator()(CollisionObject* object) const
{
mCollisionObjectManager->mCollisionDetector->notifyCollisionObjectDestroying(
mCollisionObjectManager->getCollisionDetector()->notifyCollisionObjectDestroying(
object);

delete object;
Expand Down Expand Up @@ -180,8 +187,8 @@ void
CollisionDetector::ManagerForSharableCollisionObjects
::CollisionObjectDeleter::operator()(CollisionObject* object) const
{
mCollisionObjectManager->mCollisionDetector->notifyCollisionObjectDestroying(
object);
mCollisionObjectManager->getCollisionDetector()
->notifyCollisionObjectDestroying(object);
mCollisionObjectManager->mCollisionObjectMap.erase(object->getShapeFrame());

delete object;
Expand Down
3 changes: 3 additions & 0 deletions dart/collision/CollisionDetector.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,9 @@ class CollisionDetector::CollisionObjectManager
virtual std::shared_ptr<CollisionObject> claimCollisionObject(
const dynamics::ShapeFrame* shapeFrame) = 0;

/// Returns collision detector
CollisionDetector* getCollisionDetector();

protected:

CollisionDetector* mCollisionDetector;
Expand Down
2 changes: 1 addition & 1 deletion dart/collision/fcl/FCLCollisionDetector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,7 @@ ::fcl::BVHModel<BV>* createCylinder(double _baseRadius, double _topRadius,
/* Cache is the vertex locations cache */
for (i = 0; i < _slices; i++)
{
angle = 2 * M_PI * i / _slices;
angle = 2 * math::constantsd::pi() * i / _slices;
sinCache[i] = sin(angle);
cosCache[i] = cos(angle);
}
Expand Down
1 change: 1 addition & 0 deletions dart/common/Resource.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@

#include <cstddef>
#include <memory>
#include <string>

namespace dart {
namespace common {
Expand Down
8 changes: 0 additions & 8 deletions dart/common/SharedLibrary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,25 +38,17 @@
#if DART_OS_LINUX || DART_OS_MACOS

#include <dlfcn.h>
#define DYNLIB_HANDLE void*
#define DYNLIB_LOAD(a) dlopen(a, RTLD_LAZY | RTLD_GLOBAL)
#define DYNLIB_GETSYM(a, b) dlsym(a, b)
#define DYNLIB_UNLOAD(a) dlclose(a)

#elif DART_OS_WINDOWS

#define WIN32_LEAN_AND_MEAN
#if !defined(NOMINMAX) && defined(_MSC_VER)
#define NOMINMAX // required to stop windows.h messing up std::min
#endif
#include <windows.h>
#define DYNLIB_HANDLE hInstance
// We can not use LOAD_WITH_ALTERED_SEARCH_PATH with relative paths
#define DYNLIB_LOAD(a) LoadLibraryEx(a, nullptr, 0)
#define DYNLIB_GETSYM(a, b) GetProcAddress(a, b)
#define DYNLIB_UNLOAD(a) !FreeLibrary(a)
struct HINSTANCE__;
typedef struct HINSTANCE__* hInstance;

#endif

Expand Down
14 changes: 14 additions & 0 deletions dart/common/SharedLibrary.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,25 @@
#include "dart/common/Platform.hpp"

#if DART_OS_LINUX

#define DYNLIB_HANDLE void*

#elif DART_OS_MACOS

#define DYNLIB_HANDLE void*

#elif DART_OS_WINDOWS

#ifdef NOMINMAX
#include <windows.h>
#else
#define NOMINMAX
#include <windows.h>
#undef NOMINMAX
#endif
using hInstance = HINSTANCE__*;
#define DYNLIB_HANDLE hInstance

#endif

namespace dart {
Expand Down
12 changes: 7 additions & 5 deletions dart/dynamics/ArrowShape.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@

#include "dart/dynamics/ArrowShape.hpp"

#include "dart/math/Constants.hpp"

namespace dart {
namespace dynamics {

Expand Down Expand Up @@ -119,7 +121,7 @@ static void constructArrowTip(aiMesh* mesh, double base, double tip,
std::size_t resolution = (mesh->mNumVertices-1)/2;
for(std::size_t i=0; i<resolution; ++i)
{
double theta = (double)(i)/(double)(resolution)*2*M_PI;
double theta = (double)(i)/(double)(resolution)*2*math::constantsd::pi();

double R = properties.mRadius;
double x = R*cos(theta);
Expand All @@ -146,7 +148,7 @@ static void constructArrowBody(aiMesh* mesh, double z1, double z2,
std::size_t resolution = mesh->mNumVertices/2;
for(std::size_t i=0; i<resolution; ++i)
{
double theta = (double)(i)/(double)(resolution)*2*M_PI;
double theta = (double)(i)/(double)(resolution)*2*math::constantsd::pi();

double R = properties.mRadius;
double x = R*cos(theta);
Expand Down Expand Up @@ -283,15 +285,15 @@ void ArrowShape::instantiate(std::size_t resolution)
{
mesh->mNormals[2*i].Set(0.0f, 0.0f, 1.0f);

double theta = (double)(i)/(double)(resolution)*2*M_PI;
double theta = (double)(i)/(double)(resolution)*2*math::constantsd::pi();
mesh->mNormals[2*i+1].Set(cos(theta), sin(theta), 0.0f);
}
mesh->mNormals[mesh->mNumVertices-1].Set(0.0f, 0.0f, -1.0f);

mesh = scene->mMeshes[1];
for(std::size_t i=0; i<resolution; ++i)
{
double theta = (double)(i)/(double)(resolution)*2*M_PI;
double theta = (double)(i)/(double)(resolution)*2*math::constantsd::pi();
mesh->mNormals[2*i].Set(cos(theta), sin(theta), 0.0f);
mesh->mNormals[2*i+1].Set(cos(theta), sin(theta), 0.0f);
}
Expand All @@ -301,7 +303,7 @@ void ArrowShape::instantiate(std::size_t resolution)
{
mesh->mNormals[2*i].Set(0.0f, 0.0f, -1.0f);

double theta = (double)(i)/(double)(resolution)*2*M_PI;
double theta = (double)(i)/(double)(resolution)*2* math::constantsd::pi();
mesh->mNormals[2*i+1].Set(cos(theta), sin(theta), 0.0f);
}
mesh->mNormals[mesh->mNumVertices-1].Set(0.0f, 0.0f, 1.0f);
Expand Down
2 changes: 1 addition & 1 deletion dart/gui/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ find_package(OpenGL QUIET)
dart_check_optional_package(OPENGL "dart-gui" "OpenGL")

if(WIN32 AND NOT CYGWIN)
set(GLUT_INCLUDE_DIR "@CMAKE_INSTALL_PREFIX@/include")
set(GLUT_INCLUDE_DIR "${CMAKE_INSTALL_PREFIX}/include")
set(GLUT_LIBRARIES glut32)
set(HAVE_GLUT TRUE)
else()
Expand Down
Loading