From f55292466757c382c83dcb6f558798468b53eef4 Mon Sep 17 00:00:00 2001 From: Sylvain Thery Date: Tue, 15 Jul 2014 17:24:38 +0200 Subject: [PATCH] Visual compilation --- Apps/CMakeLists.txt | 24 ++++++------------ README_VISUAL.TXT | 35 +++++++++++---------------- ThirdParty/CMakeLists.txt | 25 +++++++++++-------- apps_cmake.txt | 17 +++++++------ include/Container/convert.h | 2 +- src/Utils/Shaders/shaderWallPaper.cpp | 8 +++--- src/Utils/pickables.cpp | 8 +++--- 7 files changed, 55 insertions(+), 64 deletions(-) diff --git a/Apps/CMakeLists.txt b/Apps/CMakeLists.txt index 2487b968..8f92e91c 100644 --- a/Apps/CMakeLists.txt +++ b/Apps/CMakeLists.txt @@ -6,28 +6,18 @@ ELSE (ONELIB) ENDIF (ONELIB) -#IF(${CMAKE_BUILD_TYPE} MATCHES Release|release|RELEASE) -# SET(CGoGN_LIBS ${CGoGN_LIBS_R}) -#ELSE() -# SET(CGoGN_LIBS ${CGoGN_LIBS_D}) -#ENDIF() - - -#IF(WIN32) -# link_directories(${CGoGN_ROOT_DIR}/lib/$(ConfigurationName) -# ${Boost_LIBRARY_DIRS}) -#ELSE(WIN32) - -SET(EXECUTABLE_OUTPUT_PATH ${CGoGN_ROOT_DIR}/bin/${CMAKE_BUILD_TYPE} ) - -link_directories( ${CGoGN_ROOT_DIR}/lib/${CMAKE_BUILD_TYPE} ) +IF (WIN32) + link_directories( ${CGoGN_ROOT_DIR}/lib/${ConfigurationName} ${Boost_LIBRARY_DIRS}) + SET(EXECUTABLE_OUTPUT_PATH ${CGoGN_ROOT_DIR}/bin/) # Release/Debug added automatically by visual +ELSE() + link_directories( ${CGoGN_ROOT_DIR}/lib/${CMAKE_BUILD_TYPE} ) + SET(EXECUTABLE_OUTPUT_PATH ${CGoGN_ROOT_DIR}/bin/${CMAKE_BUILD_TYPE} ) +ENDIF() include_directories( ${CGoGN_ROOT_DIR}/include ${CGoGN_EXT_INCLUDES}) - - IF (COMPILE_SANDBOX) add_subdirectory(SandBox) ENDIF() diff --git a/README_VISUAL.TXT b/README_VISUAL.TXT index 25ee47c8..64296837 100644 --- a/README_VISUAL.TXT +++ b/README_VISUAL.TXT @@ -1,9 +1,9 @@ - *** english version below *** + *** english version below *** Compilation sous VisualExpress C++ Prérequis: -Visual Studio ou C++ Express (testé avec 2010 express) +Visual Studio ou C++ Express 2013 (C++11 CMake (au moins 2.8) Unziper le windows_dependencies.zip (http://iggservis.u-strasbg.fr/Data/) a la racine de CGoGN @@ -11,32 +11,27 @@ Installer boost et Qt (4.8.x pas de 5.0 pour le moment) Attention installer les binaires de Qt dans une version de compilateur differente (VS2008/VS2010) permet d'executer mais pas de debugger ! -Si vous utiliser BoostPro (http://www.boostpro.com) installer toutes les versions multithread dll -pour eviter les pb de compilation. Le plus sur mais plus long est de compiler soi-même Qt et Boost (bon courage) Pour les "ThirdParty libs": Lancer CMake (gui) Mettre le chemin de la racine de CGoGN + /ThirdParty pour les sources -Mettre le chemin de la racine de CGoGN + /ThirdParty/build pour le build en release -Mettre le chemin de la racine de CGoGN + /ThirdParty/buildDebug pour le build en debug -Sous windows les 2 versions sont nécessaires. +Mettre le chemin de la racine de CGoGN + /ThirdParty/build -La suite vaut pour les 2 répertoires: Cliquer sur Configure Choisir le bon compilateur (celui de votre version de Visual C++) Modifier les variables en fonctions de ce que vous voulez compiler (README.TXT de ThirdParty) Modifier le CMAKE_PREFIX_PATH si nécessaire (cf remarque dépendances) Recliquer sur Configure Cliquer sur Generate -Aller sous visual, charger et compiler les 2 solutions +Aller sous visual, charger et compiler en Release et Debug Ne pas oublier de générer la cible INSTALL (une seule fois) Pour CGoGN: Relancer CMake Mettre le chemin de la racine de CGoGN pour les sources -Mettre le chemin de la racine de CGoGN + /build (par exemple) pour le build +Mettre le chemin de la racine de CGoGN + /build pour le build Cliquer sur Configure Choisir le bon compilateur (celui de votre version de Visual C++) Modifier les variables comme pour ThirdParty (et CMAKE_PREFIX_PATH si nécessaire) @@ -44,6 +39,7 @@ Recliquer sur Configure Cliquer sur Generate Si il ne trouve pas Qt lui remplir la variable QT_QMAKE_EXECUTABLE +Si il ne trouve pas boost, remplir la variable Boost_INCLUDE_DIR (C:\Boost1.55\include par exemple) Aller dans Visual et double-cliquer sur CGoGN.sln !! @@ -61,7 +57,6 @@ Si vous voulez utiliser vos propre versions des dépendance (Zlib / glew / Boost changer le CMAKE_PREFIX_PATH (voir ci dessous) Attention pour Boost le prefix path ne marche pas (utiliser BOOST_ROOT et d'autres si nécessaire) - Compilation 64bits: TODO @@ -81,34 +76,28 @@ Install boost and Qt Warning installing the binaries of Qt in a version of different compilers (VS2008/VS2010) allows you to run but not in debug mode! -If you use BoostPro (http://www.boostpro.com) install all versions multithreaded dll -to avoid the pb of compilation. - The safest but longest is to compile Qt yourself and Boost (good luck) For the "ThirdParty libs" Run CMake (gui) -Put the path to the root of CGoGN + / ThirdParty sources for -Put the path to the root of CGoGN + / ThirdParty / build to build in release -Put the path to the root of CGoGN + / ThirdParty / buildDebug to build in debug -Under windows the two versions are needed. +Put the path to the root of CGoGN + / ThirdParty sources for sources +Put the path to the root of CGoGN + / ThirdParty / build for build -The following applies to two directories: Click on Configure Choosing the right compiler (your version of Visual C + +) Change the variables in functions that you want to compile (README.TXT for ThirdParty) Edit CMAKE_PREFIX_PATH if necessary (see note dependencies) Click again on Configure Click on Generate -Go on visual, load and compile the 2 solutions +Go on visual, load and compile the solution in Release and Debug Do not forgot to generate the target INSTALL (once) For CGoGN: Restart CMake Put the path to the root of CGoGN for sources -Put the path to the root of CGoGN + / build (for example) to build +Put the path to the root of CGoGN + / build to build Click on Configure Choosing the right compiler (your version of Visual C + +) Change the variables as ThirdParty (and CMAKE_PREFIX_PATH if necessary) @@ -116,6 +105,10 @@ Click again on Configure Click on Generate Go to Visual and double-click on CGoGN.sln! +If it does not found Qt fill the QT_QMAKE_EXECUTABLE variable. +If it does not found boost, fill the Boost_INCLUDE_DIR variable (C:\Boost1.55\include for example) + + WARNING: Problem of linking with QGLViewer in Debug If you compile an example (tuto1 & viewer) in Debug you have to modifiy the project: Configuration properties -> Linking Editor -> Entries -> Supplementary dependencies diff --git a/ThirdParty/CMakeLists.txt b/ThirdParty/CMakeLists.txt index 7a7f35c3..9f3c5d29 100644 --- a/ThirdParty/CMakeLists.txt +++ b/ThirdParty/CMakeLists.txt @@ -1,27 +1,36 @@ -cmake_minimum_required(VERSION 2.6) +cmake_minimum_required(VERSION 2.8) project(CGoGN_ThirdParty) SET(CGoGN_ROOT_DIR ${CMAKE_SOURCE_DIR}/..) IF(WIN32) - set(CMAKE_PREFIX_PATH ${CGoGN_ROOT_DIR}/windows_dependencies CACHE STRING "path to dependencies") + ENDIF(WIN32) IF (${CMAKE_CURRENT_BINARY_DIR} MATCHES "(.*)Debug") -# SET(CMAKE_BUILD_TYPE Debug) set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Debug/Release" FORCE) ELSE() -# SET(CMAKE_BUILD_TYPE Release) set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Debug/Release" FORCE) ENDIF() IF(WIN32) + set(CMAKE_PREFIX_PATH ${CGoGN_ROOT_DIR}/windows_dependencies CACHE STRING "path to dependencies") INCLUDE_DIRECTORIES(${CGoGN_ROOT_DIR}/windows_dependencies/include/) INCLUDE_DIRECTORIES(${CGoGN_ROOT_DIR}/windows_dependencies/include/suitesparse) + SET(LIBRARY_OUTPUT_PATH ${CGoGN_ROOT_DIR}/lib) + set(CMAKE_CONFIGURATION_TYPES Release Debug) +# SET(CMAKE_CONFIGURATION_TYPES ${CMAKE_BUILD_TYPE}) +# SET(CMAKE_CONFIGURATION_TYPES "${CMAKE_CONFIGURATION_TYPES}" CACHE STRING "" FORCE) +# MARK_AS_ADVANCED(CMAKE_CONFIGURATION_TYPES) +ELSE() + SET(LIBRARY_OUTPUT_PATH ${CGoGN_ROOT_DIR}/lib/${CMAKE_BUILD_TYPE}) +ENDIF() +IF(WIN32) + ENDIF(WIN32) -SET(LIBRARY_OUTPUT_PATH ${CGoGN_ROOT_DIR}/lib/${CMAKE_BUILD_TYPE}) + # for shared or not shared SET (BUILD_SHARED_LIBS OFF CACHE BOOL @@ -59,8 +68,4 @@ IF (WITH_ASSIMP) ENDIF (WITH_ASSIMP) -IF(WIN32) - SET(CMAKE_CONFIGURATION_TYPES ${CMAKE_BUILD_TYPE}) - SET(CMAKE_CONFIGURATION_TYPES "${CMAKE_CONFIGURATION_TYPES}" CACHE STRING "" FORCE) - MARK_AS_ADVANCED(CMAKE_CONFIGURATION_TYPES) -ENDIF(WIN32) + diff --git a/apps_cmake.txt b/apps_cmake.txt index 9605f356..9782c2e4 100644 --- a/apps_cmake.txt +++ b/apps_cmake.txt @@ -116,7 +116,7 @@ IF(WIN32) set(CMAKE_PREFIX_PATH ${CGoGN_ROOT_DIR}/windows_dependencies CACHE STRING "path to dependencies") set(CMAKE_CONFIGURATION_TYPES Release Debug) set(CMAKE_CONFIGURATION_TYPES "${CMAKE_CONFIGURATION_TYPES}" CACHE STRING "Only Release or Debug" FORCE) -ELSE(WIN32) +ELSE() SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -fPIC -std=c++11") SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pg") @@ -125,17 +125,20 @@ ELSE(WIN32) if (GCC_VERSION VERSION_GREATER 4.8 OR GCC_VERSION VERSION_EQUAL 4.8) SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-local-typedefs") SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused-local-typedefs") - endif(GCC_VERSION VERSION_GREATER 4.8 OR GCC_VERSION VERSION_EQUAL 4.8) - endif(CMAKE_COMPILER_IS_GNUCXX) -ENDIF(WIN32) + endif() + endif() + +ENDIF() SET(EXECUTABLE_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/bin/${CMAKE_BUILD_TYPE}) IF(WIN32) - link_directories( ${CGoGN_ROOT_DIR}/lib/ ${Boost_LIBRARY_DIRS} ) -ELSE (WIN32) + link_directories( ${CGoGN_ROOT_DIR}/lib/${ConfigurationName} ${Boost_LIBRARY_DIRS}) + SET(EXECUTABLE_OUTPUT_PATH ${CGoGN_ROOT_DIR}/bin/) # Release/Debug added automatically by visual +ELSE () link_directories( ${CGoGN_ROOT_DIR}/lib/${CMAKE_BUILD_TYPE}) -ENDIF (WIN32) + SET(EXECUTABLE_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/bin/${CMAKE_BUILD_TYPE}) +ENDIF () IF(NOT CMAKE_BUILD_TYPE) IF (${CMAKE_CURRENT_BINARY_DIR} MATCHES "(.*)Debug|(.*)debug") diff --git a/include/Container/convert.h b/include/Container/convert.h index 5044b142..8fadfabe 100644 --- a/include/Container/convert.h +++ b/include/Container/convert.h @@ -354,7 +354,7 @@ public: for (unsigned int i = 0; i < m_nb; ++i) { const Geom::Vec3d& vd = *typedIn++; - *typedOut++ = Geom::Vec3f(vd[0],vd[1],vd[2]); + *typedOut++ = Geom::Vec3f(float(vd[0]),float(vd[1]),float(vd[2])); // Geom::Vec3f& vf = *typedOut++; // vf[0]=vd[0];vf[1]=vd[1];vf[2]=vd[2]; } diff --git a/src/Utils/Shaders/shaderWallPaper.cpp b/src/Utils/Shaders/shaderWallPaper.cpp index ac58f24e..1365969e 100644 --- a/src/Utils/Shaders/shaderWallPaper.cpp +++ b/src/Utils/Shaders/shaderWallPaper.cpp @@ -53,10 +53,10 @@ ShaderWallPaper::ShaderWallPaper(): m_vboPos->allocate(4); Geom::Vec3f* ptrPos = reinterpret_cast(m_vboPos->lockPtr()); - ptrPos[0] = Geom::Vec3f(-1,-1, 0.9999999); - ptrPos[1] = Geom::Vec3f( 1,-1, 0.9999999); - ptrPos[2] = Geom::Vec3f( 1, 1, 0.9999999); - ptrPos[3] = Geom::Vec3f(-1, 1, 0.9999999); + ptrPos[0] = Geom::Vec3f(-1,-1, 0.9999999f); + ptrPos[1] = Geom::Vec3f( 1,-1, 0.9999999f); + ptrPos[2] = Geom::Vec3f( 1, 1, 0.9999999f); + ptrPos[3] = Geom::Vec3f(-1, 1, 0.9999999f); m_vboPos->releasePtr(); diff --git a/src/Utils/pickables.cpp b/src/Utils/pickables.cpp index 9efc506d..e53188bf 100644 --- a/src/Utils/pickables.cpp +++ b/src/Utils/pickables.cpp @@ -422,14 +422,14 @@ void Sphere::changeTopo(unsigned int parp, unsigned int mer) for (unsigned int i=0; i