From 4a567a442ac0d844a894e5de071d51a505d07f4a Mon Sep 17 00:00:00 2001 From: srit Date: Mon, 8 Feb 2010 00:24:34 +0000 Subject: [PATCH] More MSVC stuff --- CMakeLists.txt | 4 +- cmake/common.cmake | 4 +- common/clitkCommon.h | 12 ++---- common/clitkPortability.h | 10 +++++ common/clitkTimer.cxx | 14 +++++++ common/clitkTimer.h | 16 ++++++-- vv/CMakeLists.txt | 78 ++++++++++++++++++--------------------- 7 files changed, 80 insertions(+), 58 deletions(-) create mode 100755 common/clitkPortability.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 8476152..7c6adeb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,7 +7,9 @@ if(COMMAND cmake_policy) endif(COMMAND cmake_policy) PROJECT(clitk) #========================================================= -SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native") +IF(CMAKE_COMPILER_IS_GNUCXX) + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native") +ENDIF(CMAKE_COMPILER_IS_GNUCXX) #========================================================= # Find ITK (required) FIND_PACKAGE(ITK) diff --git a/cmake/common.cmake b/cmake/common.cmake index d710720..d661d56 100644 --- a/cmake/common.cmake +++ b/cmake/common.cmake @@ -18,8 +18,8 @@ FOREACH(GGO_FILE ${ALL_GGO_FILES}) #MESSAGE(${GGO_C}) SET(GGO_OUTPUT ${GGO_H} ${GGO_C}) ADD_CUSTOM_COMMAND(OUTPUT ${GGO_OUTPUT} - COMMAND gengetopt - ARGS < ${GGO_FILE} --arg-struct-name=args_info_${GGO_NAME} --file-name=${GGO_BASEFILENAME}_ggo -u --conf-parser + COMMAND ${CLITK_GENGETOPT}/gengetopt + ARGS < ${GGO_FILE} --arg-struct-name=args_info_${GGO_NAME} --file-name=${GGO_BASEFILENAME}_ggo -u --conf-parser --include-getopt DEPENDS ${GGO_FILE} ) ENDFOREACH(GGO_FILE) diff --git a/common/clitkCommon.h b/common/clitkCommon.h index 4f7a9fa..c4d772d 100644 --- a/common/clitkCommon.h +++ b/common/clitkCommon.h @@ -11,6 +11,9 @@ -------------------------------------------------------------------*/ +// clitk include +#include "clitkPortability.h" + // std include //#include //#include @@ -33,15 +36,6 @@ //-------------------------------------------------------------------- namespace clitk { - -#if defined(WIN32) -# define lrint(x) (floor(x+(x>0) ? 0.5 : -0.5)) -#endif - -#ifndef M_PI -# define M_PI 3.141592653589793238462643 -#endif - typedef unsigned char uchar; typedef unsigned short ushort; diff --git a/common/clitkPortability.h b/common/clitkPortability.h new file mode 100755 index 0000000..da1b7ba --- /dev/null +++ b/common/clitkPortability.h @@ -0,0 +1,10 @@ +#ifndef CLITKPORTABILITY_H +#define CLITKPORTABILITY_H + +#if defined(WIN32) +# define rint(x) floor(x+0.5) +# define lrint(x) (long)rint(x) +# define _USE_MATH_DEFINES +#endif + +#endif /* end #define CLITKPORTABILITY_H */ diff --git a/common/clitkTimer.cxx b/common/clitkTimer.cxx index 85b65fd..6f39dc0 100644 --- a/common/clitkTimer.cxx +++ b/common/clitkTimer.cxx @@ -20,23 +20,37 @@ /// Constructs the class clitk::Timer::Timer() { Reset(); +#if defined(WIN32) + QueryPerformanceFrequency((LARGE_INTEGER*)&mFrequency); +#endif } //==================================================================== //==================================================================== void clitk::Timer::Start() { +#if defined(UNIX) getrusage(RUSAGE_SELF, &mBegin); +#elif defined(WIN32) + QueryPerformanceCounter((LARGE_INTEGER*)&mBegin); +#endif mNumberOfCall++; } //==================================================================== //==================================================================== void clitk::Timer::Stop(bool accumulate) { +#if defined(UNIX) getrusage(RUSAGE_SELF, &mEnd); if (accumulate) { mElapsed += (mEnd.ru_utime.tv_usec - mBegin.ru_utime.tv_usec)+ (mEnd.ru_utime.tv_sec - mBegin.ru_utime.tv_sec)*1000000; } +#elif defined(WIN32) + QueryPerformanceCounter((LARGE_INTEGER*)&mEnd); + if (accumulate) { + mElapsed += ((mEnd-mBegin)*1000000)/(long double)mFrequency; + } +#endif else { mNumberOfCall--; } diff --git a/common/clitkTimer.h b/common/clitkTimer.h index 5f651c3..87edf5b 100644 --- a/common/clitkTimer.h +++ b/common/clitkTimer.h @@ -11,12 +11,14 @@ ===================================================================*/ -// #ifdef UNIX - #include "clitkCommon.h" #include -#include -#include +#if defined(UNIX) +# include +# include +#elif defined(WIN32) +# include +#endif #include #include @@ -41,8 +43,14 @@ namespace clitk { //==================================================================== protected: +#if defined(UNIX) rusage mBegin; rusage mEnd; +#elif defined(WIN32) + unsigned __int64 mBegin; + unsigned __int64 mEnd; + unsigned __int64 mFrequency; +#endif long double mElapsed; long int mNumberOfCall; }; diff --git a/vv/CMakeLists.txt b/vv/CMakeLists.txt index 1b76974..266d457 100644 --- a/vv/CMakeLists.txt +++ b/vv/CMakeLists.txt @@ -1,13 +1,6 @@ cmake_minimum_required(VERSION 2.4) #========================================================= INCLUDE(${PROJECT_SOURCE_DIR}/cmake/common.cmake) -#========================================================= - -#Set a reasonable build mode default if the user hasn't set any -if (NOT CMAKE_BUILD_TYPE) - set(CMAKE_BUILD_TYPE RelWithDebInfo) -endif (NOT CMAKE_BUILD_TYPE) - #========================================================= # Find ITK (required) FIND_PACKAGE(ITK) @@ -237,45 +230,46 @@ ENDIF (CLITK_VV_USE_BDCM) #========================================================= # Installation file INSTALL(TARGETS vv vv - RUNTIME DESTINATION bin CONFIGURATIONS relwithdebinfo - LIBRARY DESTINATION lib CONFIGURATIONS relwithdebinfo - ARCHIVE DESTINATION lib CONFIGURATIONS relwithdebinfo) + RUNTIME DESTINATION bin CONFIGURATIONS ${CMAKE_BUILD_TYPE} + LIBRARY DESTINATION lib CONFIGURATIONS ${CMAKE_BUILD_TYPE} + ARCHIVE DESTINATION lib CONFIGURATIONS ${CMAKE_BUILD_TYPE}) INSTALL(FILES ${vv_HDRS} DESTINATION include) IF(WIN32) - INSTALL (FILES ${CMAKE_CURRENT_SOURCE_DIR}/ducky.png DESTINATION bin) - INSTALL (FILES ${EXECUTABLE_OUTPUT_PATH}relwithdebinfo/vv.exe DESTINATION bin) + INSTALL (FILES ${CMAKE_CURRENT_SOURCE_DIR}/icons/ducky.png DESTINATION bin) + INSTALL (FILES ${EXECUTABLE_OUTPUT_PATH}/${CMAKE_BUILD_TYPE}/vv.exe DESTINATION bin) INSTALL (FILES ${QT_PLUGINS_DIR}/../bin/QtCore4.dll DESTINATION bin) INSTALL (FILES ${QT_PLUGINS_DIR}/../bin/QtGui4.dll DESTINATION bin) - INSTALL (FILES ${VTK_DIR}/bin/relwithdebinfo/vtkCommon.dll DESTINATION bin) - INSTALL (FILES ${VTK_DIR}/bin/relwithdebinfo/vtksys.dll DESTINATION bin) - INSTALL (FILES ${VTK_DIR}/bin/relwithdebinfo/vtkRendering.dll DESTINATION bin) - INSTALL (FILES ${VTK_DIR}/bin/relwithdebinfo/vtkGraphics.dll DESTINATION bin) - INSTALL (FILES ${VTK_DIR}/bin/relwithdebinfo/vtkImaging.dll DESTINATION bin) - INSTALL (FILES ${VTK_DIR}/bin/relwithdebinfo/vtkFiltering.dll DESTINATION bin) - INSTALL (FILES ${VTK_DIR}/bin/relwithdebinfo/vtkGenericFiltering.dll DESTINATION bin) - INSTALL (FILES ${VTK_DIR}/bin/relwithdebinfo/vtkIO.dll DESTINATION bin) - INSTALL (FILES ${VTK_DIR}/bin/relwithdebinfo/verdict.dll DESTINATION bin) - INSTALL (FILES ${VTK_DIR}/bin/relwithdebinfo/QVTK.dll DESTINATION bin) - INSTALL (FILES ${VTK_DIR}/bin/relwithdebinfo/QVTKWidgetPlugin.dll DESTINATION bin) - INSTALL (FILES ${VTK_DIR}/bin/relwithdebinfo/vtkDICOMParser.dll DESTINATION bin) - INSTALL (FILES ${VTK_DIR}/bin/relwithdebinfo/vtkexoIIc.dll DESTINATION bin) - INSTALL (FILES ${VTK_DIR}/bin/relwithdebinfo/vtkexpat.dll DESTINATION bin) - INSTALL (FILES ${VTK_DIR}/bin/relwithdebinfo/vtkmetaio.dll DESTINATION bin) - INSTALL (FILES ${VTK_DIR}/bin/relwithdebinfo/vtkftgl.dll DESTINATION bin) - INSTALL (FILES ${VTK_DIR}/bin/relwithdebinfo/vtkfreetype.dll DESTINATION bin) - INSTALL (FILES ${VTK_DIR}/bin/relwithdebinfo/vtkGenericFiltering.dll DESTINATION bin) - INSTALL (FILES ${VTK_DIR}/bin/relwithdebinfo/vtkHybrid.dll DESTINATION bin) - INSTALL (FILES ${VTK_DIR}/bin/relwithdebinfo/vtkInfovis.dll DESTINATION bin) - INSTALL (FILES ${VTK_DIR}/bin/relwithdebinfo/vtkjpeg.dll DESTINATION bin) - INSTALL (FILES ${VTK_DIR}/bin/relwithdebinfo/vtklibxml2.dll DESTINATION bin) - INSTALL (FILES ${VTK_DIR}/bin/relwithdebinfo/vtkNetCDF.dll DESTINATION bin) - INSTALL (FILES ${VTK_DIR}/bin/relwithdebinfo/vtkpng.dll DESTINATION bin) - INSTALL (FILES ${VTK_DIR}/bin/relwithdebinfo/vtktiff.dll DESTINATION bin) - INSTALL (FILES ${VTK_DIR}/bin/relwithdebinfo/vtkViews.dll DESTINATION bin) - INSTALL (FILES ${VTK_DIR}/bin/relwithdebinfo/vtkVolumeRendering.dll DESTINATION bin) - INSTALL (FILES ${VTK_DIR}/bin/relwithdebinfo/vtkWidgets.dll DESTINATION bin) - INSTALL (FILES ${VTK_DIR}/bin/relwithdebinfo/vtkzlib.dll DESTINATION bin) + INSTALL (FILES ${ITK_DIR}/bin/${CMAKE_BUILD_TYPE}/itkCommon.dll DESTINATION bin) + INSTALL (FILES ${VTK_DIR}/bin/${CMAKE_BUILD_TYPE}/vtkCommon.dll DESTINATION bin) + INSTALL (FILES ${VTK_DIR}/bin/${CMAKE_BUILD_TYPE}/vtksys.dll DESTINATION bin) + INSTALL (FILES ${VTK_DIR}/bin/${CMAKE_BUILD_TYPE}/vtkRendering.dll DESTINATION bin) + INSTALL (FILES ${VTK_DIR}/bin/${CMAKE_BUILD_TYPE}/vtkGraphics.dll DESTINATION bin) + INSTALL (FILES ${VTK_DIR}/bin/${CMAKE_BUILD_TYPE}/vtkImaging.dll DESTINATION bin) + INSTALL (FILES ${VTK_DIR}/bin/${CMAKE_BUILD_TYPE}/vtkFiltering.dll DESTINATION bin) + INSTALL (FILES ${VTK_DIR}/bin/${CMAKE_BUILD_TYPE}/vtkGenericFiltering.dll DESTINATION bin) + INSTALL (FILES ${VTK_DIR}/bin/${CMAKE_BUILD_TYPE}/vtkIO.dll DESTINATION bin) + INSTALL (FILES ${VTK_DIR}/bin/${CMAKE_BUILD_TYPE}/vtkverdict.dll DESTINATION bin) + INSTALL (FILES ${VTK_DIR}/bin/${CMAKE_BUILD_TYPE}/QVTK.dll DESTINATION bin) + INSTALL (FILES ${VTK_DIR}/bin/${CMAKE_BUILD_TYPE}/QVTKWidgetPlugin.dll DESTINATION bin) + INSTALL (FILES ${VTK_DIR}/bin/${CMAKE_BUILD_TYPE}/vtkDICOMParser.dll DESTINATION bin) + INSTALL (FILES ${VTK_DIR}/bin/${CMAKE_BUILD_TYPE}/vtkexoIIc.dll DESTINATION bin) + INSTALL (FILES ${VTK_DIR}/bin/${CMAKE_BUILD_TYPE}/vtkexpat.dll DESTINATION bin) + INSTALL (FILES ${VTK_DIR}/bin/${CMAKE_BUILD_TYPE}/vtkmetaio.dll DESTINATION bin) + INSTALL (FILES ${VTK_DIR}/bin/${CMAKE_BUILD_TYPE}/vtkftgl.dll DESTINATION bin) + INSTALL (FILES ${VTK_DIR}/bin/${CMAKE_BUILD_TYPE}/vtkfreetype.dll DESTINATION bin) + INSTALL (FILES ${VTK_DIR}/bin/${CMAKE_BUILD_TYPE}/vtkGenericFiltering.dll DESTINATION bin) + INSTALL (FILES ${VTK_DIR}/bin/${CMAKE_BUILD_TYPE}/vtkHybrid.dll DESTINATION bin) + INSTALL (FILES ${VTK_DIR}/bin/${CMAKE_BUILD_TYPE}/vtkInfovis.dll DESTINATION bin) + INSTALL (FILES ${VTK_DIR}/bin/${CMAKE_BUILD_TYPE}/vtkjpeg.dll DESTINATION bin) + INSTALL (FILES ${VTK_DIR}/bin/${CMAKE_BUILD_TYPE}/vtklibxml2.dll DESTINATION bin) + INSTALL (FILES ${VTK_DIR}/bin/${CMAKE_BUILD_TYPE}/vtkNetCDF.dll DESTINATION bin) + INSTALL (FILES ${VTK_DIR}/bin/${CMAKE_BUILD_TYPE}/vtkpng.dll DESTINATION bin) + INSTALL (FILES ${VTK_DIR}/bin/${CMAKE_BUILD_TYPE}/vtktiff.dll DESTINATION bin) + INSTALL (FILES ${VTK_DIR}/bin/${CMAKE_BUILD_TYPE}/vtkViews.dll DESTINATION bin) + INSTALL (FILES ${VTK_DIR}/bin/${CMAKE_BUILD_TYPE}/vtkVolumeRendering.dll DESTINATION bin) + INSTALL (FILES ${VTK_DIR}/bin/${CMAKE_BUILD_TYPE}/vtkWidgets.dll DESTINATION bin) + INSTALL (FILES ${VTK_DIR}/bin/${CMAKE_BUILD_TYPE}/vtkzlib.dll DESTINATION bin) ENDIF(WIN32) IF(UNIX) @@ -300,7 +294,7 @@ IF(WIN32 AND NOT UNIX) # There is a bug in NSI that does not handle full unix paths properly. Make # sure there is at least one set of four (4) backlasshes. SET(CPACK_PACKAGE_ICON "${CMAKE_CURRENT_SOURCE_DIR}\\\\ducky.png") - SET(CPACK_NSIS_INSTALLED_ICON_NAME "bin/relwithdebinfo\\\\vv.exe") + SET(CPACK_NSIS_INSTALLED_ICON_NAME "bin/${CMAKE_BUILD_TYPE}\\\\vv.exe") SET(CPACK_NSIS_DISPLAY_NAME "${CPACK_PACKAGE_INSTALL_DIRECTORY} The 4D slicer") SET(CPACK_NSIS_HELP_LINK "http://www.creatis.insa-lyon.fr/rio") SET(CPACK_NSIS_URL_INFO_ABOUT "http://www.creatis.insa-lyon.fr/rio") -- 2.47.1