Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
5f51f04
[cmake] fix msvc flags
simogasp May 23, 2020
45dfdbe
[cmake] set c++11 flags
simogasp May 23, 2020
d244042
[cmake] CMAKE_POSITION_INDEPENDENT_CODE no for win
simogasp May 23, 2020
1f3efd7
[cmake] do not propagate c++11 and fpic for msvc
simogasp May 23, 2020
fe24ce6
[cmake] try non deprecated flag first --expt-relaxed-constexp
simogasp May 23, 2020
ea320e1
[cmake] simplify msvc
simogasp May 23, 2020
a81e02f
[cmake] only for ninja generator
simogasp May 23, 2020
bccc660
[cmake] fix order of import tbb
simogasp May 24, 2020
12b831a
[cmake] set lib version and debug postfix
simogasp May 24, 2020
8e1ac15
[cmake] CMAKE_POSITION_INDEPENDENT_CODE for apps project
simogasp May 24, 2020
fc96468
[cmake] fix -pie for apps
simogasp May 24, 2020
53a9099
[cmake] tbb version is not updated
simogasp May 24, 2020
f488ee8
[cmake] generate targets files in build-tree
simogasp May 24, 2020
6b35eaf
[cmake] all build output in [Linux|Windows|Darwin]arch folder
simogasp May 24, 2020
120e1c0
[cmake] apps do not define new project if included by another
simogasp May 24, 2020
5a1c4e4
[cmake] apps with build postfix and version
simogasp May 24, 2020
05066d0
[cmake] use GNUInstallDirs
simogasp May 24, 2020
04a91a7
[cmake] cctag_uninstall
simogasp May 24, 2020
2524c93
[cmake] prepend CCTAG_ to BUILD_APPS and BUILD_TESTS
simogasp May 24, 2020
a428462
[cmake] switched to imported targets for eigen
simogasp May 24, 2020
29b44a2
[cmake] set a minimum version for eigen, different for msvc+cuda
simogasp May 24, 2020
38f7c5f
[cmake] add option CCTAG_EIGEN_NO_ALIGN
simogasp May 24, 2020
74df806
[cmake] find dependency for eigen in Config
simogasp May 24, 2020
805fbc1
[cmake] version string
simogasp May 24, 2020
339b143
[cmake] config and version headers in {generated}/cctag
simogasp May 24, 2020
dde4088
[cmake] add include dirs for generated
simogasp May 24, 2020
bcece9a
[cmake] find dependency for eigen with version
simogasp May 24, 2020
2cfada9
[cmake] remove -std=c++11
simogasp May 24, 2020
460bf5f
[cmake] CUDA_ADD_LIBRARY now allows to define include
simogasp May 24, 2020
958dff7
[cmake] add recap summary
simogasp May 24, 2020
f8465d1
fixup! [cmake] CUDA_ADD_LIBRARY now allows to define include
simogasp May 24, 2020
69ba17d
remove spurious file
simogasp May 24, 2020
6cbfbd4
[cmake] install headers with explicit list
simogasp May 24, 2020
272efed
[cmake] using CMAKE_RUNTIME_OUTPUT_DIRECTORY CMAKE_LIBRARY_OUTPUT_DIR…
simogasp May 30, 2020
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
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ addons:
packages:
- g++-4.8
- clang-3.8
- libeigen3-dev
- libpng-dev
- libjpeg8-dev
- libtiff4-dev
Expand Down
125 changes: 103 additions & 22 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,69 @@ include(ExternalProject)

project(CCTag VERSION 1.0.0 LANGUAGES C CXX)

# Set build path as a folder named as the platform (linux, windows, darwin...) plus the processor type
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR}")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR}")

include(GNUInstallDirs)

#CMakeDependentOption
option(CCTAG_SERIALIZE "Store all the output" OFF)
option(CCTAG_VISUAL_DEBUG "Enable visual debug" OFF)
option(CCTAG_NO_COUT "Disable output stream" ON)
option(CCTAG_WITH_CUDA "Compile the library with CUDA support" ON)
option(BUILD_APPS "Build the sample applications" ON)
option(CCTAG_BUILD_APPS "Build the sample applications" ON)
option(CCTAG_CUDA_CC_CURRENT_ONLY "Set to on to build only for the current machine's CC" OFF)
option(CCTAG_NVCC_WARNINGS "Switch on several additional warnings for CUDA nvcc." OFF)
option(CCTAG_EIGEN_NO_ALIGN "Disable Eigen alignment" ON)

option(CCTAG_USE_POSITION_INDEPENDENT_CODE "Generate position independent code." ON)
option(CCTAG_ENABLE_SIMD_AVX2 "Enable AVX2 optimizations" OFF)
option(BUILD_TESTS "Build the unity tests" ON)
option(CCTAG_BUILD_TESTS "Build the unity tests" ON)
option(CCTAG_NO_THRUST_COPY_IF "Do not use thrust::copy_if() on GPU. There may be a bug on CUDA 7 with GTX 980, 980Ti and 1080" OFF)

if(NOT CMAKE_BUILD_TYPE AND NOT MSVC)
set(CMAKE_BUILD_TYPE "Release")
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/cmake")

# set(CMAKE_BUILD_TYPE Debug)
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
set(CMAKE_BUILD_TYPE Release)
message(STATUS "Build type not set, building in Release configuration")
# Set the possible values of build type for cmake-gui
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo")
else()
message(STATUS "Building in ${CMAKE_BUILD_TYPE} configuration")
endif()

# ensure the proper linker flags when building the static version on MSVC
if(MSVC AND NOT BUILD_SHARED_LIBS)
foreach(config "DEBUG" "RELEASE" "MINSIZEREL" "RELWITHDEBINFO")
string(REPLACE /MD /MT CMAKE_C_FLAGS_${config} "${CMAKE_C_FLAGS_${config}}")
string(REPLACE /MD /MT CMAKE_CXX_FLAGS_${config} "${CMAKE_CXX_FLAGS_${config}}")
message(STATUS "CMAKE_C_FLAGS_${config} ${CMAKE_C_FLAGS_${config}}")
message(STATUS "CMAKE_CXX_FLAGS_${config} ${CMAKE_CXX_FLAGS_${config}}")
endforeach()
endif()

# this is to ensure that on MSVC the flags for the linker are properly propagate even to the intermediate
# linking step. This seems not the case e.g. on vcpkg using ninja build.
if(MSVC AND CMAKE_GENERATOR MATCHES "Ninja")
if(BUILD_SHARED_LIBS)
set(CCTAG_MVSC_LINKER "/MD")
else()
set(CCTAG_MVSC_LINKER "/MT")
endif()
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
set(CCTAG_MVSC_LINKER "${CCTAG_MVSC_LINKER}d")
endif()
list(APPEND CUDA_NVCC_FLAGS -Xcompiler ${CCTAG_MVSC_LINKER})
endif()

set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CUDA_STANDARD 11)
set(CMAKE_CUDA_STANDARD_REQUIRED ON)


if(CCTAG_ENABLE_SIMD_AVX2)
if(CMAKE_COMPILER_IS_GNUCXX OR (CMAKE_CXX_COMPILER_ID STREQUAL "Clang"))
add_definitions(-mavx2)
Expand All @@ -36,14 +81,13 @@ if(CCTAG_ENABLE_SIMD_AVX2)
message(STATUS "CCTAG: AVX2 optimizations enabled.")
endif()

if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
if(MSVC)
add_definitions(/EHsc) # Enable Exception Handling
endif()

set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

set(CMAKE_POSITION_INDEPENDENT_CODE ${CCTAG_USE_POSITION_INDEPENDENT_CODE})
if(NOT MSVC)
set(CMAKE_POSITION_INDEPENDENT_CODE ${CCTAG_USE_POSITION_INDEPENDENT_CODE})
endif()


# set the path where we can find the findXXX.cmake
Expand Down Expand Up @@ -77,7 +121,7 @@ else()
set(BOOST_REQUIRED_COMPONENTS "${BOOST_REQUIRED_COMPONENTS};stacktrace_basic")
endif()

if(BUILD_TESTS)
if(CCTAG_BUILD_TESTS)
set(BOOST_REQUIRED_COMPONENTS "${BOOST_REQUIRED_COMPONENTS};unit_test_framework")
enable_testing()
include(BoostTestHelper)
Expand Down Expand Up @@ -140,20 +184,22 @@ if(CCTAG_WITH_CUDA)
CUDA_SELECT_NVCC_ARCH_FLAGS(ARCH_FLAGS ${CCTAG_CUDA_CC_LIST_BASIC})
LIST(APPEND CUDA_NVCC_FLAGS ${ARCH_FLAGS})

set(CUDA_NVCC_FLAGS "${CUDA_NVCC_FLAGS};-std=c++11")
if(NOT MSVC)
set(CUDA_NVCC_FLAGS "${CUDA_NVCC_FLAGS};-std=c++11")
endif()
set(CUDA_NVCC_FLAGS "${CUDA_NVCC_FLAGS};--default-stream;per-thread")

if(CCTAG_USE_POSITION_INDEPENDENT_CODE)
if(CCTAG_USE_POSITION_INDEPENDENT_CODE AND NOT MSVC)
set(CUDA_NVCC_FLAGS "${CUDA_NVCC_FLAGS};-Xcompiler;-fPIC")
endif()

CCTAG_CHECK_NVCC_COMPILER_FLAG("--relaxed-constexpr" HAS_NVCC_RELAXED_CONSTEXPR)
if(HAS_NVCC_RELAXED_CONSTEXPR)
set(CUDA_NVCC_FLAGS "${CUDA_NVCC_FLAGS};--relaxed-constexpr")
CCTAG_CHECK_NVCC_COMPILER_FLAG("--expt-relaxed-constexpr" HAS_NVCC_EXPT_RELAXED_CONSTEXPR)
if(HAS_NVCC_EXPT_RELAXED_CONSTEXPR)
set(CUDA_NVCC_FLAGS "${CUDA_NVCC_FLAGS};--expt-relaxed-constexpr")
else()
CCTAG_CHECK_NVCC_COMPILER_FLAG("--expt-relaxed-constexpr" HAS_NVCC_EXPT_RELAXED_CONSTEXPR)
if(HAS_NVCC_EXPT_RELAXED_CONSTEXPR)
set(CUDA_NVCC_FLAGS "${CUDA_NVCC_FLAGS};--expt-relaxed-constexpr")
CCTAG_CHECK_NVCC_COMPILER_FLAG("--relaxed-constexpr" HAS_NVCC_RELAXED_CONSTEXPR)
if(HAS_NVCC_RELAXED_CONSTEXPR)
set(CUDA_NVCC_FLAGS "${CUDA_NVCC_FLAGS};--relaxed-constexpr")
endif()
endif()

Expand All @@ -177,19 +223,54 @@ endif(CCTAG_WITH_CUDA)
find_package(OpenCV REQUIRED core videoio imgproc imgcodecs)

# FIND Eigen
find_package(Eigen REQUIRED)
set(CCTAG_EIGEN_REQUIRED_VERSION 3.3.4)
if(MSVC AND CCTAG_WITH_CUDA)
set(CCTAG_EIGEN_REQUIRED_VERSION 3.3.9)
message(WARNING "Building CCTag with Cuda support under windows requires Eigen >= ${CCTAG_EIGEN_REQUIRED_VERSION}")
endif()
find_package(Eigen3 ${CCTAG_EIGEN_REQUIRED_VERSION} REQUIRED)
message(STATUS "Found Eigen: version ${Eigen3_VERSION}")
if(CCTAG_EIGEN_NO_ALIGN)
set(AV_EIGEN_DEFINITIONS -DEIGEN_MAX_ALIGN_BYTES=0 -DEIGEN_MAX_STATIC_ALIGN_BYTES=0)
endif()

# FIND Intel TBB
# With MVSC, CMAKE_BUILD_TYPE will always be None, so TBB_USE_DEBUG_BUILD will always be false.
string(COMPARE EQUAL "${CMAKE_BUILD_TYPE}" Debug TBB_USE_DEBUG_BUILD)
find_package(TBB 4 REQUIRED)
find_package(TBB REQUIRED)

add_subdirectory(src)

########### Add uninstall target ###############
CONFIGURE_FILE(
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/cmake/cmake_uninstall.cmake"
IMMEDIATE @ONLY)
ADD_CUSTOM_TARGET(uninstall
add_custom_target(cctag_uninstall
"${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake/cmake_uninstall.cmake")


######################################
# SUMMARY
######################################
message("\n")
message("******************************************")
message("Building configuration:\n")
message(STATUS "CCTag version: " ${PROJECT_VERSION})
message(STATUS "Build type: " ${CMAKE_BUILD_TYPE})
message(STATUS "Build Shared libs: " ${BUILD_SHARED_LIBS})
message(STATUS "Build applications: " ${CCTAG_BUILD_APPS})
message(STATUS "Build tests: " ${CCTAG_BUILD_TESTS})
message(STATUS "Cuda support: " ${CCTAG_WITH_CUDA})
if(CCTAG_WITH_CUDA)
message(STATUS "Compiling for CUDA CCs: ${ARCH_FLAGS}")
endif()
message(STATUS "Disable Eigen alignment: " ${CCTAG_EIGEN_NO_ALIGN})
message(STATUS "Enable AVX2 optimizations: " ${CCTAG_ENABLE_SIMD_AVX2})
message(STATUS "[debug] Serialize all the output: " ${CCTAG_SERIALIZE})
message(STATUS "[debug] Enable visual debug: " ${CCTAG_VISUAL_DEBUG})
message(STATUS "[debug] Disable output stream: " ${CCTAG_NO_COUT})
message(STATUS "[debug] nvcc additional warnings: " ${CCTAG_NVCC_WARNINGS})
message(STATUS "Install path: " ${CMAKE_INSTALL_PREFIX})
message("\n******************************************")
message("\n")
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ RUN cmake -j -DBUILD_TIFF=ON \
-DWITH_TBB=ON \
-DWITH_EIGEN=ON \
-DWITH_V4L=ON \
-DBUILD_TESTS=OFF \
-DCCTAG_BUILD_TESTS=OFF \
-DBUILD_PERF_TESTS=OFF \
-DCMAKE_BUILD_TYPE=RELEASE .. \
&& make -j install \
Expand Down
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ install:
before_build:
- md build
- cd build
- cmake -G "Visual Studio 14 2015" -A x64 -T v140,host=x64 -DCMAKE_BUILD_TYPE=%configuration% -DCMAKE_TOOLCHAIN_FILE=c:/tools/vcpkg/scripts/buildsystems/vcpkg.cmake -DBUILD_APPS:BOOL=ON -DCCTAG_WITH_CUDA:BOOL=OFF -DCCTAG_SERIALIZE:BOOL=ON -DCCTAG_VISUAL_DEBUG:BOOL=ON ..
- cmake -G "Visual Studio 14 2015" -A x64 -T v140,host=x64 -DCMAKE_BUILD_TYPE=%configuration% -DCMAKE_TOOLCHAIN_FILE=c:/tools/vcpkg/scripts/buildsystems/vcpkg.cmake -DCCTAG_BUILD_APPS:BOOL=ON -DCCTAG_WITH_CUDA:BOOL=OFF -DCCTAG_SERIALIZE:BOOL=ON -DCCTAG_VISUAL_DEBUG:BOOL=ON ..
- ls -l

build:
Expand Down
1 change: 1 addition & 0 deletions cmake/Config.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ include(CMakeFindDependencyMacro)

set(OpenCV_DIR @OpenCV_DIR@)
find_dependency(OpenCV)
find_dependency(Eigen3 @CCTAG_EIGEN_REQUIRED_VERSION@)
find_dependency(Boost 1.66 REQUIRED COMPONENTS @BOOST_REQUIRED_COMPONENTS@)

include("${CMAKE_CURRENT_LIST_DIR}/@targets_export_name@.cmake")
Expand Down
166 changes: 0 additions & 166 deletions cmake/FindEigen.cmake

This file was deleted.

Loading