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

Add Visual Studio compiler option /FS for Ninja build #2414

Merged
merged 3 commits into from
Sep 6, 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
121 changes: 63 additions & 58 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ set(CMAKE_CONFIGURATION_TYPES "Debug;Release" CACHE STRING "possible configurati
# In case the user does not setup CMAKE_BUILD_TYPE, assume it's RelWithDebInfo
if("${CMAKE_BUILD_TYPE}" STREQUAL "")
set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "build type default to RelWithDebInfo, set to Release to improve performance" FORCE)
endif("${CMAKE_BUILD_TYPE}" STREQUAL "")
endif()

project(PCL)
string(TOLOWER ${PROJECT_NAME} PROJECT_NAME_LOWER)
Expand All @@ -38,7 +38,7 @@ string(TOLOWER ${PROJECT_NAME} PROJECT_NAME_LOWER)
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules/" ${CMAKE_MODULE_PATH})

# ---[ Include pkgconfig
include (FindPkgConfig)
include(FindPkgConfig)

# ---[ Release/Debug specific flags
if(CMAKE_BUILD_TYPE STREQUAL "Release" OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
Expand Down Expand Up @@ -103,13 +103,13 @@ include("${PCL_SOURCE_DIR}/cmake/pcl_options.cmake")
if(CMAKE_TIMING_VERBOSE AND UNIX)
set_property(GLOBAL PROPERTY RULE_MESSAGES OFF)
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "${CMAKE_SOURCE_DIR}/cmake/custom_output.sh")
endif(CMAKE_TIMING_VERBOSE AND UNIX)
endif()

# check for SSE flags
include("${PCL_SOURCE_DIR}/cmake/pcl_find_sse.cmake")
if (PCL_ENABLE_SSE)
if(PCL_ENABLE_SSE)
PCL_CHECK_FOR_SSE()
endif (PCL_ENABLE_SSE)
endif()

# ---[ Unix/Darwin/Windows specific flags
if(CMAKE_COMPILER_IS_GNUCXX)
Expand All @@ -119,13 +119,13 @@ if(CMAKE_COMPILER_IS_GNUCXX)
# Enable -Wabi for GCC > 4.3, and -Wno-deprecated for GCC < 4.3
# to disable a lot of warnings which are not fixable
execute_process(COMMAND ${CMAKE_C_COMPILER} -dumpversion OUTPUT_VARIABLE GCC_VERSION)
if (GCC_VERSION VERSION_GREATER 4.3)
if(GCC_VERSION VERSION_GREATER 4.3)
message(STATUS "-- GCC > 4.3 found, enabling -Wabi")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wabi")
else()
message(STATUS "-- GCC < 4.3 found, enabling -Wno-deprecated")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated")
endif ()
endif()
endif()

if(NOT ANDROID)
Expand All @@ -139,18 +139,19 @@ if(CMAKE_COMPILER_IS_GNUCXX)
if(WIN32)
if(PCL_SHARED_LIBS)
SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--export-all-symbols -Wl,--enable-auto-import")
if (MINGW)
if(MINGW)
add_definitions("-DBOOST_THREAD_USE_LIB")
SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--allow-multiple-definition")
endif()
else(PCL_SHARED_LIBS)
else()
add_definitions("-DBOOST_LIB_DIAGNOSTIC -DBOOST_THREAD_USE_LIB")
endif(PCL_SHARED_LIBS)
endif()
endif()
endif()

if(CMAKE_COMPILER_IS_MSVC)
add_definitions("-DBOOST_ALL_NO_LIB -D_SCL_SECURE_NO_WARNINGS -D_CRT_SECURE_NO_WARNINGS -DNOMINMAX -DPCL_ONLY_CORE_POINT_TYPES /bigobj ${SSE_DEFINITIONS}")

if("${CMAKE_CXX_FLAGS}" STREQUAL "/DWIN32 /D_WINDOWS /W3 /GR /EHsc") # Check against default flags
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /bigobj /fp:precise /wd4800 /wd4521 /wd4251 /wd4275 /wd4305 /wd4355 ${SSE_FLAGS}")

Expand All @@ -159,18 +160,23 @@ if(CMAKE_COMPILER_IS_MSVC)
SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /GL")
SET(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} /LTCG /OPT:REF")
SET(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /LTCG")
endif(CMAKE_MSVC_CODE_LINK_OPTIMIZATION)
endif()
# /MANIFEST:NO") # please, don't disable manifest generation, otherwise crash at start for vs2008

if(MSVC_VERSION GREATER 1500 AND ${CMAKE_VERSION} VERSION_GREATER "2.8.6")
include(ProcessorCount)
ProcessorCount(N)
if(NOT N EQUAL 0)
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /MP${N}")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /MP${N}")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP${N}")
endif()
endif()
endif()

if(CMAKE_GENERATOR STREQUAL "Ninja")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /FS")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /FS")
endif()
endif()

if(CMAKE_COMPILER_IS_PATHSCALE)
Expand Down Expand Up @@ -204,7 +210,7 @@ SET_INSTALL_DIRS()
if(WIN32)
set(PCL_RESOURCES_DIR "${PCL_SOURCE_DIR}/resources")
set(PCL_POINTCLOUDS_DIR "${PCL_RESOURCES_DIR}/pointclouds")
endif(WIN32)
endif()

set(PCL_OUTPUT_LIB_DIR "${PCL_BINARY_DIR}/${LIB_INSTALL_DIR}")
set(PCL_OUTPUT_BIN_DIR "${PCL_BINARY_DIR}/${BIN_INSTALL_DIR}")
Expand All @@ -221,9 +227,9 @@ if(WIN32)
# ---[ Windows requires DLLs (shared libraries) to be installed in the same directory as executables
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_${CONFIG} "${PCL_OUTPUT_BIN_DIR}")
endforeach(config)
else(WIN32)
else()
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${PCL_OUTPUT_LIB_DIR}")
endif(WIN32)
endif()

# Add an "uninstall" target
configure_file("${PCL_SOURCE_DIR}/cmake/uninstall_target.cmake.in"
Expand Down Expand Up @@ -252,7 +258,7 @@ endif()
if(OPENMP_FOUND)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
message (STATUS "Found OpenMP")
message(STATUS "Found OpenMP")
if(MSVC)
if(MSVC_VERSION EQUAL 1500)
set(OPENMP_DLL VCOMP90)
Expand All @@ -270,12 +276,12 @@ if(OPENMP_FOUND)
if(OPENMP_DLL)
set(CMAKE_SHARED_LINKER_FLAGS_DEBUG "${CMAKE_SHARED_LINKER_FLAGS_DEBUG} /DELAYLOAD:${OPENMP_DLL}D.dll")
set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} /DELAYLOAD:${OPENMP_DLL}.dll")
else(OPENMP_DLL)
else()
message(WARNING "Delay loading flag for OpenMP DLL is invalid.")
endif(OPENMP_DLL)
endif()
endif(MSVC)
else(OPENMP_FOUND)
message (STATUS "Not found OpenMP")
else()
message(STATUS "Not found OpenMP")
endif()

# Eigen (required)
Expand All @@ -285,7 +291,7 @@ include_directories(SYSTEM ${EIGEN_INCLUDE_DIRS})
# FLANN (required)
if(NOT PCL_SHARED_LIBS OR ((WIN32 AND NOT MINGW) AND NOT PCL_BUILD_WITH_FLANN_DYNAMIC_LINKING_WIN32))
set(FLANN_USE_STATIC ON)
endif(NOT PCL_SHARED_LIBS OR ((WIN32 AND NOT MINGW) AND NOT PCL_BUILD_WITH_FLANN_DYNAMIC_LINKING_WIN32))
endif()
find_package(FLANN 1.7.0 REQUIRED)
include_directories(${FLANN_INCLUDE_DIRS})

Expand All @@ -295,8 +301,8 @@ if(WITH_LIBUSB)
find_package(libusb-1.0)
if(LIBUSB_1_FOUND)
include_directories("${LIBUSB_1_INCLUDE_DIR}")
endif(LIBUSB_1_FOUND)
endif(WITH_LIBUSB)
endif()
endif()

# Dependencies for different grabbers
PCL_ADD_GRABBER_DEPENDENCY("OpenNI" "OpenNI grabber support")
Expand All @@ -308,10 +314,10 @@ PCL_ADD_GRABBER_DEPENDENCY("DSSDK" "DepthSense SDK support")
PCL_ADD_GRABBER_DEPENDENCY("RSSDK" "RealSense SDK support")

# metslib
if (PKG_CONFIG_FOUND)
if(PKG_CONFIG_FOUND)
pkg_check_modules(METSLIB metslib)
if (METSLIB_FOUND)
set (HAVE_METSLIB ON)
if(METSLIB_FOUND)
set(HAVE_METSLIB ON)
include_directories(${METSLIB_INCLUDE_DIRS})
else()
include_directories("${PCL_SOURCE_DIR}/recognition/include/pcl/recognition/3rdparty/")
Expand All @@ -324,44 +330,44 @@ endif()
option(WITH_PNG "PNG file support" TRUE)
if(WITH_PNG)
find_package(PNG)
if (PNG_FOUND)
set (HAVE_PNG ON)
if(PNG_FOUND)
set(HAVE_PNG ON)
include_directories("${PNG_INCLUDE_DIR}")
endif(PNG_FOUND)
endif(WITH_PNG)
endif()
endif()

# Qhull
option(WITH_QHULL "Include convex-hull operations" TRUE)
if(WITH_QHULL)
if(NOT PCL_SHARED_LIBS)
set(QHULL_USE_STATIC ON)
endif(NOT PCL_SHARED_LIBS)
endif()
find_package(Qhull)
if(QHULL_FOUND)
include_directories(${QHULL_INCLUDE_DIRS})
endif(QHULL_FOUND)
endif(WITH_QHULL)
endif()
endif()

# Cuda
option(WITH_CUDA "Build NVIDIA-CUDA support" TRUE)
if(WITH_CUDA)
include("${PCL_SOURCE_DIR}/cmake/pcl_find_cuda.cmake")
endif(WITH_CUDA)
endif()

option(WITH_QT "Build QT Front-End" TRUE)
if(WITH_QT)
set(PCL_QT_VERSION 5 CACHE STRING "Which QT version to use")
if("${PCL_QT_VERSION}" STREQUAL "4")
find_package(Qt4)
if (QT4_FOUND)
if(QT4_FOUND)
include("${QT_USE_FILE}")
endif (QT4_FOUND)
endif()
elseif("${PCL_QT_VERSION}" STREQUAL "5")
include(cmake/pcl_find_qt5.cmake)
else()
message(SEND_ERROR "PCL_QT_VERSION must be 4 or 5")
endif()
endif(WITH_QT)
endif()

# Find VTK
option(WITH_VTK "Build VTK-Visualizations" TRUE)
Expand All @@ -374,51 +380,50 @@ if(WITH_VTK AND NOT ANDROID)
set(VTK_RENDERING_BACKEND "OpenGL")
endif()
message(STATUS "VTK_MAJOR_VERSION ${VTK_MAJOR_VERSION}, rendering backend: ${VTK_RENDERING_BACKEND}")
if (PCL_SHARED_LIBS OR
(NOT (PCL_SHARED_LIBS) AND NOT (VTK_BUILD_SHARED_LIBS)))
if(PCL_SHARED_LIBS OR (NOT (PCL_SHARED_LIBS) AND NOT (VTK_BUILD_SHARED_LIBS)))
set(VTK_FOUND TRUE)
find_package (QVTK)
if (${VTK_MAJOR_VERSION} VERSION_LESS "6.0")
find_package(QVTK)
if(${VTK_MAJOR_VERSION} VERSION_LESS "6.0")
message(STATUS "VTK found (include: ${VTK_INCLUDE_DIRS}, lib: ${VTK_LIBRARY_DIRS})")
link_directories(${VTK_LIBRARY_DIRS})
else(${VTK_MAJOR_VERSION} VERSION_LESS "6.0")
include (${VTK_USE_FILE})
else()
include(${VTK_USE_FILE})
message(STATUS "VTK found (include: ${VTK_INCLUDE_DIRS}, lib: ${VTK_LIBRARIES}")
endif (${VTK_MAJOR_VERSION} VERSION_LESS "6.0")
if (APPLE)
option (VTK_USE_COCOA "Use Cocoa for VTK render windows" ON)
MARK_AS_ADVANCED (VTK_USE_COCOA)
endif (APPLE)
endif()
if(APPLE)
option(VTK_USE_COCOA "Use Cocoa for VTK render windows" ON)
MARK_AS_ADVANCED(VTK_USE_COCOA)
endif()
if(${VTK_RENDERING_BACKEND} STREQUAL "OpenGL")
set(VTK_RENDERING_BACKEND_OPENGL_VERSION "1")
elseif(${VTK_RENDERING_BACKEND} STREQUAL "OpenGL2")
set(VTK_RENDERING_BACKEND_OPENGL_VERSION "2")
endif()
set(HAVE_VTK ON)
else ()
else()
set(VTK_FOUND OFF)
set(HAVE_VTK OFF)
message ("Warning: You are to build PCL in STATIC but VTK is SHARED!")
message ("Warning: VTK disabled!")
endif ()
endif(VTK_FOUND)
else(WITH_VTK AND NOT ANDROID)
message("Warning: You are to build PCL in STATIC but VTK is SHARED!")
message("Warning: VTK disabled!")
endif()
endif()
else()
set(VTK_FOUND OFF)
set(HAVE_VTK OFF)
endif(WITH_VTK AND NOT ANDROID)
endif()


#Find PCAP
option(WITH_PCAP "pcap file capabilities in Velodyne HDL driver" TRUE)
if(WITH_PCAP)
find_package(Pcap)
endif(WITH_PCAP)
endif()

# OpenGL and GLUT
option(WITH_OPENGL "Support for OpenGL" TRUE)
if(WITH_OPENGL)
include("${PCL_SOURCE_DIR}/cmake/pcl_find_gl.cmake")
endif(WITH_OPENGL)
endif()

# Boost (required)
include("${PCL_SOURCE_DIR}/cmake/pcl_find_boost.cmake")
Expand Down Expand Up @@ -462,7 +467,7 @@ if(CPACK_GENERATOR)
PCL_MAKE_CPACK_INPUT()
set(CPACK_PROJECT_CONFIG_FILE "${PCL_CPACK_CFG_FILE}")
include(CPack)
endif(CPACK_GENERATOR)
endif()
### ---[ Make a pretty picture of the dependency graph
include("${PCL_SOURCE_DIR}/cmake/dep_graph.cmake")
MAKE_DEP_GRAPH()
Expand Down
Loading