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

Correcting Cmake files for Windows and Visual Studio, and adding d suffix for the generated library in debug mode #1395

Merged
merged 6 commits into from
Feb 28, 2019
Merged
Show file tree
Hide file tree
Changes from 3 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
2 changes: 2 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@
(Boris Mansencal, [#1380](https:/DGtal-team/DGtal/pull/1380))
- Fixing & updating Travis: documentation deployement and DGtalTools job
(Roland Denis, [#1383](https:/DGtal-team/DGtal/pull/1383))
- Fix compilation with Visual Studio and adding debug version for the generated file
(Raphael Lenain)

- *Base*
- Fixing wrong members in PredicateCombiner (David Coeurjolly,
Expand Down
11 changes: 10 additions & 1 deletion cmake/Common.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ foreach(p LIB BIN INCLUDE DATA)
endif()
endforeach()

# -----------------------------------------------------------------------------
# To distinguish between debug and release lib
# -----------------------------------------------------------------------------
set(CMAKE_DEBUG_POSTFIX "d")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would this also apply on linux/mac builds ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On Linux, if we want the indicate the debug or release configuration, the "-DCMAKE_BUILD_TYPE" option has to be added :

  • for Debug : "cmake -DCMAKE_BUILD_TYPE=Debug"
  • for Release : "cmake -DCMAKE_BUILD_TYPE=Debug" (or "cmake", Release is the default configuration)
    With this new line in Common.cmake(set(CMAKE_DEBUG_POSTFIX "d")) :
  • for Debug configuration, the generated file is libdgtald.so (on Windows : DGtald.lib)
  • for Release configuration, the generated file is libdgtal.so (on Windows : DGtal.lib)

For Mac I cannot perform any test, but I imagine it's the same thing than on Linux.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know that but was just wondering if the "d" suffix would also be used by cmake on linux for the dynamic lib construction.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

which is not standard for me

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(and would imply a tweak of the FindDGtal)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm doing some tests for an alternative solution (without changing DGtal Cmake file :-) ). But the 2 errors on Visual studio are "_ITERATOR_DEBUG_LEVEL" and "RuntimeLibrary" : "https://docs.microsoft.com/en-us/cpp/error-messages/tool-errors/linker-tools-error-lnk2038?view=vs-2017"

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can edit the cmake if you want (only for MSVC). I don't undrestand why VC complains but not a big deal if that fixes the issue

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I succeeded compiling my project in Debug mode, referencing the Release version of DGtal.
When creating a new project on Visual Studio, the IDE automatically :

  • for the Debug configuration : adds a preprocessor macro "_DEBUG" (--> _ITERATOR_DEBUG_LEVEL = 2), and sets the property "UseDebugLibraries" to true (--> RuntimeLibrary : Debug)
  • for the Release configuration : adds a preprocessor macro "NDEBUG" (--> _ITERATOR_DEBUG_LEVEL = 0), and sets the property "UseDebugLibraries" to false (--> RuntimeLibrary : Release)

So compiling in Debug mode, linking to the Release version of DGtal, is possible, changing these configurations, but it's not the default configuration for Visual Studio.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I add the "MSVC" test

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👌


# -----------------------------------------------------------------------------
# Doxygen targets
# -----------------------------------------------------------------------------
Expand All @@ -52,7 +57,11 @@ ADD_CUSTOM_TARGET(uninstall
# -----------------------------------------------------------------------------
# Parsing cmake options
# -----------------------------------------------------------------------------
OPTION(BUILD_SHARED_LIBS "Build shared libraries." ON)
IF (MSVC)
OPTION(BUILD_SHARED_LIBS "Build shared libraries." OFF)
ELSE (MSVC)
OPTION(BUILD_SHARED_LIBS "Build shared libraries." ON)
ENDIF (MSVC)
OPTION(BUILD_TESTING "Build testing." OFF)
OPTION(DEBUG_VERBOSE "Verbose debug messages." OFF)
OPTION(VERBOSE "Verbose messages." OFF)
Expand Down
14 changes: 7 additions & 7 deletions cmake/DGtalConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ ENDIF(@COLOR_WITH_ALPHA_ARITH_DGTAL@)
# When user or compiler have not set any std flag.
try_compile( CPP11_COMPATIBLE_FLAG_SET_BY_USER
${CMAKE_BINARY_DIR}/CMakeTmp
@DGTAL_CMAKE_DIR@/cpp11_check.cpp
"@DGTAL_CMAKE_DIR@/cpp11_check.cpp"
CMAKE_FLAGS "-DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}"
OUTPUT_VARIABLE OUTPUT
)
Expand Down Expand Up @@ -120,7 +120,7 @@ ENDIF(@HDF5_FOUND_DGTAL@)
if (@QGLVIEWER_FOUND_DGTAL@)
add_definitions("-DWITH_VISU3D_QGLVIEWER ")
set(WITH_VISU3D_QGLVIEWER 1)
set(DGTAL_INCLUDE_DIRS ${DGTAL_INCLUDE_DIRS} @QGLVIEWER_INCLUDE_DIR@)
set(DGTAL_INCLUDE_DIRS ${DGTAL_INCLUDE_DIRS} "@QGLVIEWER_INCLUDE_DIR@")
endif (@QGLVIEWER_FOUND_DGTAL@)

#-- We force the Qt rediscovering
Expand All @@ -130,7 +130,7 @@ if (@QT4_FOUND_DGTAL@)
add_definitions("-DWITH_QT4")
set(WITH_QT4 1)
include(${QT_USE_FILE})
set(DGTAL_INCLUDE_DIRS ${DGTAL_INCLUDE_DIRS} ${QT_INCLUDE_DIR})
set(DGTAL_INCLUDE_DIRS ${DGTAL_INCLUDE_DIRS} "${QT_INCLUDE_DIR}")
endif (@QT4_FOUND_DGTAL@)

if (@QT5_FOUND_DGTAL@)
Expand All @@ -139,9 +139,9 @@ if (@QT5_FOUND_DGTAL@)
set(WITH_QT5 1)
set(Qt5_DIR @Qt5_DIR@)
set(DGTAL_INCLUDE_DIRS ${DGTAL_INCLUDE_DIRS}
${Qt5Widgets_INCLUDE_DIRS}
${Qt5OpenGL_INCLUDE_DIRS}
${Qt5Xml_INCLUDE_DIRS})
"${Qt5Widgets_INCLUDE_DIRS}"
"${Qt5OpenGL_INCLUDE_DIRS}"
"${Qt5Xml_INCLUDE_DIRS}")
endif (@QT5_FOUND_DGTAL@)

IF(@OPENMP_FOUND_DGTAL@)
Expand All @@ -156,7 +156,7 @@ ENDIF(@OPENMP_FOUND_DGTAL@)
IF(@EIGEN_FOUND_DGTAL@)
ADD_DEFINITIONS("-DWITH_EIGEN ")
SET(WITH_EIGEN 1)
SET(DGTAL_INCLUDE_DIRS ${DGTAL_INCLUDE_DIRS} @EIGEN3_INCLUDE_DIR@ )
SET(DGTAL_INCLUDE_DIRS ${DGTAL_INCLUDE_DIRS} "@EIGEN3_INCLUDE_DIR@" )
ENDIF(@EIGEN_FOUND_DGTAL@)


Expand Down
8 changes: 6 additions & 2 deletions cmake/FindFFTW3.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ find_library (FFTW3_LONG_THREADS_LIBRARIES NAMES fftw3l_threads )
# Gathering FFTW3 libraries
set (FFTW3_LIBRARIES ${FFTW3_FLOAT_LIBRARIES} ${FFTW3_DOUBLE_LIBRARIES} ${FFTW3_LONG_LIBRARIES})
set (FFTW3_THREADS_LIBRARIES ${FFTW3_FLOAT_THREADS_LIBRARIES} ${FFTW3_DOUBLE_THREADS_LIBRARIES} ${FFTW3_LONG_THREADS_LIBRARIES})
set (FFTW3_DEP_LIBRARIES m)
if (NOT MSVC)
set (FFTW3_DEP_LIBRARIES m)
endif (NOT MSVC)

# Telling which FFT precisions are found.
include(FindPackageHandleStandardArgs)
Expand All @@ -36,7 +38,9 @@ FIND_PACKAGE_HANDLE_STANDARD_ARGS(FFTW3_LONG DEFAULT_MSG FFTW3_INCLUDE_DIR FFT
# Adding threaded version of FFTW3
if (FFTW3_THREADS_LIBRARIES)
set (FFTW3_LIBRARIES ${FFTW3_LIBRARIES} ${FFTW3_THREADS_LIBRARIES})
set (FFTW3_DEP_LIBRARIES ${FFTW3_DEP_LIBRARIES} pthread)
if (NOT MSVC)
set (FFTW3_DEP_LIBRARIES ${FFTW3_DEP_LIBRARIES} pthread)
endif (NOT MSVC)
dcoeurjo marked this conversation as resolved.
Show resolved Hide resolved
endif (FFTW3_THREADS_LIBRARIES)


Expand Down
4 changes: 2 additions & 2 deletions cmake/TargetDoxygenDox.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ IF (DOXYGEN_FOUND)
SET (TMP "${CMAKE_CURRENT_BINARY_DIR}\\Doc\\html\\index.hhp")
STRING(REGEX REPLACE "[/]" "\\\\" HHP_FILE ${TMP} )
# MESSAGE(SEND_ERROR "DBG HHP_FILE=${HHP_FILE}")
ADD_CUSTOM_TARGET(winhelp ${HTML_HELP_COMPILER} ${HHP_FILE})
ADD_DEPENDENCIES (winhelp doc)
ADD_CUSTOM_TARGET(winhelp-dox ${HTML_HELP_COMPILER} ${HHP_FILE})
ADD_DEPENDENCIES (winhelp-dox dox)

IF (NOT TARGET_DOC_SKIP_INSTALL)
# install windows help?
Expand Down
4 changes: 4 additions & 0 deletions examples/tutorial-examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ SET(DGTAL_TUTO_EXAMPLES_SRC


FOREACH(FILE ${DGTAL_TUTO_EXAMPLES_SRC})
if(MSVC)
set_source_files_properties( ${FILE} PROPERTIES COMPILE_FLAGS "/bigobj" )
dcoeurjo marked this conversation as resolved.
Show resolved Hide resolved
endif(MSVC)

add_executable(${FILE} ${FILE})
target_link_libraries (${FILE} DGtal )
ENDFOREACH(FILE)
Expand Down