Post by Creator » Wed Apr 19, 2017, 20:23
The easiest way to include the DGM library into your project is to use the
find_package(DGM
) command in your CMakeLists.txt file,
e.g.:
Code: Select all
find_package(DGM 1.5 REQUIRED PATHS "$ENV{DGMDIR}/build/install")
where
"$ENV{DGMDIR}/build/install" is the path to the directory, containing the
DGMConfig.cmake file.
DGMDIR here is the system variable, pointing to the directory with the DGM library.
The
find_package(DGM
) command will set the
DGM_INCLUDE_DIRS and
DGM_LIBRARIES variables, which should be used as follows:
Code: Select all
# Properties -> C/C++ -> General -> Additional Include Directories
include_directories(${DGM_INCLUDE_DIRS})
and
Code: Select all
# Properties -> Linker -> Input -> Additional Dependencies
target_link_libraries(your_project ${DGM_LIBRARIES})
The example of a complete
CMakeLists.txt file:
Code: Select all
cmake_minimum_required (VERSION 3.1)
project (SOLUTION_NAME)
# OpenCV and DGM packages
find_package(OpenCV 3.4 REQUIRED core features2d highgui imgproc imgcodecs ml PATHS "$ENV{OPENCVDIR}/build")
find_package(DGM 1.6 REQUIRED PATHS "$ENV{DGMDIR}/build/install")
# Turn on the ability to create folders to organize projects (.vcproj)
# It creates "CMakePredefinedTargets" folder by default and adds CMake defined projects like INSTALL.vcproj and ZERO_CHECK.vcproj
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
# Sets
set(CMAKE_CONFIGURATION_TYPES "Debug;Release" CACHE STRING "" FORCE)
if(MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Zi")
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS} /DEBUG /INCREMENTAL:NO /OPT:REF /OPT:ICF")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14")
endif(MSVC)
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
# Properties -> C/C++ -> General -> Additional Include Directories
include_directories(${OpenCV_INCLUDE_DIRS} ${DGM_INCLUDE_DIRS})
#definitions
add_definitions(-D_CRT_SECURE_NO_WARNINGS -D_SCL_SECURE_NO_WARNINGS)
add_executable(PROJECT_NAME "source/main.cpp")
# Properties -> Linker -> Input -> Additional Dependencies
target_link_libraries(PROJECT_NAME ${OpenCV_LIBS} ${DGM_LIBRARIES})
The easiest way to include the DGM library into your project is to use the [b]find_package([/b]DGM[b])[/b] command in your CMakeLists.txt file, [i]e.g.[/i]:
[code]
find_package(DGM 1.5 REQUIRED PATHS "$ENV{DGMDIR}/build/install")
[/code]
where [i]"$ENV{DGMDIR}/build/install"[/i] is the path to the directory, containing the [b]DGMConfig.cmake[/b] file. [i]DGMDIR[/i] here is the system variable, pointing to the directory with the DGM library.
The [b]find_package([/b]DGM[b])[/b] command will set the [i]DGM_INCLUDE_DIRS[/i] and [i]DGM_LIBRARIES[/i] variables, which should be used as follows:
[code]
# Properties -> C/C++ -> General -> Additional Include Directories
include_directories(${DGM_INCLUDE_DIRS})
[/code]
and
[code]
# Properties -> Linker -> Input -> Additional Dependencies
target_link_libraries(your_project ${DGM_LIBRARIES})
[/code]
The example of a complete [b]CMakeLists.txt[/b] file:
[code]
cmake_minimum_required (VERSION 3.1)
project (SOLUTION_NAME)
# OpenCV and DGM packages
find_package(OpenCV 3.4 REQUIRED core features2d highgui imgproc imgcodecs ml PATHS "$ENV{OPENCVDIR}/build")
find_package(DGM 1.6 REQUIRED PATHS "$ENV{DGMDIR}/build/install")
# Turn on the ability to create folders to organize projects (.vcproj)
# It creates "CMakePredefinedTargets" folder by default and adds CMake defined projects like INSTALL.vcproj and ZERO_CHECK.vcproj
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
# Sets
set(CMAKE_CONFIGURATION_TYPES "Debug;Release" CACHE STRING "" FORCE)
if(MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Zi")
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS} /DEBUG /INCREMENTAL:NO /OPT:REF /OPT:ICF")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14")
endif(MSVC)
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
# Properties -> C/C++ -> General -> Additional Include Directories
include_directories(${OpenCV_INCLUDE_DIRS} ${DGM_INCLUDE_DIRS})
#definitions
add_definitions(-D_CRT_SECURE_NO_WARNINGS -D_SCL_SECURE_NO_WARNINGS)
add_executable(PROJECT_NAME "source/main.cpp")
# Properties -> Linker -> Input -> Additional Dependencies
target_link_libraries(PROJECT_NAME ${OpenCV_LIBS} ${DGM_LIBRARIES})
[/code]