Skip to content

Instantly share code, notes, and snippets.

@langheran
Last active July 15, 2019 05:11
Show Gist options
  • Save langheran/4569cb90f647d35416ed89bb343ac285 to your computer and use it in GitHub Desktop.
Save langheran/4569cb90f647d35416ed89bb343ac285 to your computer and use it in GitHub Desktop.
Boost cmake configuration.
#
# This is a CMake makefile. You can find the cmake utility and
# information about it at http://www.cmake.org
#
cmake_minimum_required(VERSION 3.11.4)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON CACHE STRING "VSCode Intellisense." FORCE)
option(USE_CUDA "Turn on CUDA support." ON)
set(USE_CUDA OFF)
set(CMAKE_C_COMPILER "C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/amd64/cl.exe")
set(CMAKE_CXX_COMPILER "C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/amd64/cl.exe")
set (target_name fr)
if(${USE_CUDA})
project(${target_name} LANGUAGES CUDA CXX)
else()
project(${target_name} LANGUAGES CXX C)
endif()
if(MSVC)
set(CMAKE_CXX_FLAGS "/FS /EHsc") # No pdb concurrency, no warnings, full paths for $msCompile problemMatcher.
endif()
set(CMAKE_CXX_STANDARD 11)
set(SOURCE clusteringAndIndexing/chinese_whispers.cpp
clusteringAndIndexing/evaluator.cpp
clusteringAndIndexing/glc.cpp
clusteringAndIndexing/constrained_chinese_whispers.cpp
clusteringAndIndexing/graph.cpp
common/common.cpp
common/Utils.cpp
face/FaceDescriptor_dking.cpp
test_faceclust.cpp
)
set(HEADERS clusteringAndIndexing/chinese_whispers.h
clusteringAndIndexing/evaluator.h
clusteringAndIndexing/glc.h
clusteringAndIndexing/constrained_chinese_whispers.h
clusteringAndIndexing/graph.h
common/common.h
common/get_lfw_pairs.h
common/Timing.h
common/Utils.h
face/FaceDescriptor_dking.h
test_faceclust.h
dlib/disjoint_subsets/disjoint_subsets.h
)
find_package(CUDA 8.0)
if(${CUDA_FOUND} AND ${USE_CUDA})
set(HEADERS ${HEADERS} clusteringAndIndexing/_constrained_chinese_whispers.cu)
set(CMAKE_CUDA_STANDARD 11)
set(CMAKE_CUDA_COMPILE_OBJECT ${CMAKE_CUDA_COMPILE_WHOLE_COMPILATION})
list(APPEND CUDA_NVCC_FLAGS "--std=c++11")
set(CMAKE_CUDA_SEPARABLE_COMPILATION ON)
set(CUDA_VERBOSE_BUILD ON)
message("fr.exe will use CUDA.")
else()
set(HEADERS ${HEADERS} clusteringAndIndexing/_constrained_chinese_whispers.cpp)
message("fr.exe will NOT use CUDA.")
endif()
# automatic OpenCV finding
find_package(OpenCV REQUIRED)
# if not, use manual specification of the OpenCVConfig.cmake path
# and comment previous line of automatic finding
#find_package(OpenCV REQUIRED PATHS /usr/local/share/OpenCV NO_DEFAULT_PATH)
add_definitions(-DDLIB_USE_AVX)
# add_definitions(-D_DEBUG) # Already set by MSVC
if(DEFINED _USE_CHECKPOINTS)
add_definitions(-D_USE_CHECKPOINTS=${_USE_CHECKPOINTS})
endif()
if(NOT WIN32)
set(fr_include /usr/local/include) # Needed only for Unix, vcvarsall.bat set the INCLUDE path on windows.
include_directories(${fr_include})
endif()
add_executable(fr main.cpp ${SOURCE} ${HEADERS})
if(OpenCV_FOUND)
message("-- Found OpenCV: ${OpenCV_INCLUDE_DIR} (found version ${OpenCV_VERSION})")
endif()
# set here your dlib path to cmake file
# include(C:/dlib-19.8/dlib/cmake)
string(REPLACE "\\build\\install\\lib\\cmake\\dlib" "" dlib_DIR "$ENV{dlib_DIR}")
string(REPLACE "\\" "/" dlib_DIR "${dlib_DIR}")
set(DLIB_DEBUG "${dlib_DIR}/debug_build/install/lib/cmake/dlib")
set(DLIB_RELEASE "${dlib_DIR}/release_build/install/lib/cmake/dlib")
string( TOLOWER "${CMAKE_BUILD_TYPE}" build_type_lower)
if(build_type_lower MATCHES "debug")
set(DLIB_PATH "${DLIB_DEBUG}")
endif()
if(build_type_lower MATCHES "release")
set(DLIB_PATH "${DLIB_RELEASE}")
endif()
find_package(dlib
HINTS "${DLIB_PATH}"
NO_PACKAGE_ROOT_PATH
NO_CMAKE_PATH
NO_CMAKE_ENVIRONMENT_PATH
REQUIRED
) # Look for the precompiled installation instead.
set_target_properties(dlib::dlib PROPERTIES
INTERFACE_COMPILE_OPTIONS ""
)
if(dlib_FOUND)
message("-- Found dlib: ${dlib_DIR} (found version ${dlib_VERSION})")
endif()
if(WIN32)
set(BOOST_ROOT "C:/boost")
endif ()
find_package(Boost # 1.70.0 for cmake 3.11
REQUIRED
COMPONENTS system serialization
)
message("-- Found Boost: ${Boost_INCLUDE_DIR} (found version ${Boost_VERSION})")
if(MSVC)
target_link_libraries(fr ${OpenCV_LIBS} dlib::dlib Boost::system Boost::serialization Boost::disable_autolinking Boost::dynamic_linking)
else()
target_link_libraries(fr ${OpenCV_LIBS} dlib::dlib Boost::system Boost::serialization)
endif()
# target_link_libraries(fr ${OpenCV_LIBS} dlib::dlib)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment