logo
Tags down

shadow

How CMake finds packages


By : Robin
Date : July 31 2020, 08:00 PM
With these it helps The CMP0074 policy's description tells:
code :
# This sets CMP0074 to NEW.
cmake_minimum_required(VERSION 3.12) # Or bigger version
set(BUILD_SHARED_LIBS OFF)
# If `OPENCV_ROOT` variable is set, it will be used in the next call without a warning.
find_package(OpenCV 4.2.0 REQUIRED)
# We want to support old CMake versions too!
cmake_minimum_required(VERSION 3.11) # Or lower version

# Use `OPENCV_INSTALL_PREFIX` environment variable for set `OpenCV_DIR`, which helps CMake to find OpenCV.
# This setting works for both new and old CMake versions.
file(TO_CMAKE_PATH $ENV{OPENCV_INSTALL_PREFIX} OpenCV_DIR)
IF(NOT OpenCV_DIR)
    MESSAGE( FATAL_ERROR "Please point the environment variable OPENCV_INSTALL_PREFIX to the root directory of OpenCV installation. required openCv V 4.2.x as minimum")
ENDIF()
set(BUILD_SHARED_LIBS OFF)
find_package(OpenCV 4.2.0 REQUIRED)
# 'find_package' won't use `_ROOT` variable. This suppress the corresponding warning. 
cmake_policy(SET CMP0074 OLD)
file(TO_CMAKE_PATH $ENV{OPENCV_ROOT} OpenCV_DIR)
IF(NOT OpenCV_DIR)
    MESSAGE( FATAL_ERROR "Please point the environment variable OpenCV_ROOT to the root directory of OpenCV installation. required openCv V 4.2.x as minimum")
ENDIF()
set(BUILD_SHARED_LIBS OFF)
find_package(OpenCV 4.2.0 REQUIRED)


Share : facebook icon twitter icon

CMake finds more than one main function


By : Jerry
Date : March 29 2020, 07:55 AM
I wish this helpful for you In your executable you simply have 2 main functions (print out SRC_FILES by MESSAGE(${SRC_FILES})). One is in main.cpp and one in CMakeCXXCompilerId.cpp (which is a file that CMake generates to test if your CXX compiler works correctly). The GLOB_RECURSE probably finds and adds both of these files to SRC_FILES
Using FILE(GLOB ...) is tricky:

Making a CMake library accessible by other CMake packages automatically


By : Forest
Date : March 29 2020, 07:55 AM
I hope this helps . Taking the code found in a blog post by @daniperez - Use CMake-enabled libraries in your CMake project (III) - I've come up with the following minimal solution:
myCoolLibrary/CMakeLists.txt
code :
cmake_minimum_required(VERSION 3.3)

project(myCoolLibrary)

function(my_export_target _target _include_dir)
    file(
        WRITE "${CMAKE_CURRENT_BINARY_DIR}/${_target}Config.cmake"
        "
            include(\"\$\{CMAKE_CURRENT_LIST_DIR\}/${_target}Targets.cmake\")
            set_property(
                TARGET ${_target}
                APPEND PROPERTY
                    INTERFACE_INCLUDE_DIRECTORIES \"${_include_dir}\"
            )
        "
    )

    export(TARGETS ${_target} FILE "${CMAKE_CURRENT_BINARY_DIR}/${_target}Targets.cmake")

    # NOTE: The following call can pollute your PC's CMake package registry
    #       See comments/alternatives below
    export(PACKAGE ${_target})
endfunction(my_export_target)

...

add_library(${PROJECT_NAME} SHARED ${mysources_SRC})
my_export_target(${PROJECT_NAME} "${CMAKE_CURRENT_SOURCE_DIR}")
cmake_minimum_required(VERSION 3.3)

project(myCoolExe)

find_package(myCoolLibrary REQUIRED)

...

add_executable(${PROJECT_NAME} ${my_sources_SRC})
target_link_libraries(${PROJECT_NAME} myCoolLibrary)

Add/include a Cmake that finds a package into CMake


By : Josh Hecht
Date : March 29 2020, 07:55 AM
Any of those help I found this CMake to find OpenBLAS but I can't find a way how to include that as an external file. ,
but I can't find a way how to include that as an external file.
code :
Project
└── cmake
    └── Modules
        └── FindOpenBLAS.cmake
set (CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/cmake/Modules/")
find_package (OpenBLAS REQUIRED)  
include_directories (${OpenBLAS_INCLUDE_DIR})
...
target_link_libraries (${OpenBLAS_LIB})

CMake can't find Qt4 but then finds Qt4


By : Black wolf
Date : March 29 2020, 07:55 AM
seems to work fine Proper name for Qt4 "Core" component is QtCore. See e.g. this question as usage example.

CMake finds wrong boost version


By : Jete
Date : March 29 2020, 07:55 AM
I wish did fix the issue. Problem solved. Apparently CMake checked a version.hpp file which was locally installed (/usr/local/include/boost), probably by me a long time ago...
Funny thing though, there was no corresponding library and CMake was also not trying to look into the default directories. I had to do the following:
Related Posts Related Posts :
  • Compiling standard library types
  • Sending argument to an .exe via SHELLEXECUTEINFO
  • Why I can't use i/10 in FOR LOOP, C++?
  • How to use PERF_SAMPLE_READ with mmap
  • Is there any way to iterate through a struct?
  • My character counting code is miscounting characters. Why?
  • Difference between std::resize(n) and std::shrink_to_fit in C++?
  • Wildcard for C++ concepts saying "accepting anything for this template argument"
  • Which of the objects of the class A would be created first in this code snippet?
  • Floating point math accuracy, c++ vs fortran
  • C++ initialize objects with packed array of integers
  • Picking a constructor to call
  • using function call in constructor gives different result c++
  • Using strcpy to copy elements of an char array to another array
  • Templated Constructor Specialization
  • Struggling to convert an integer into a linked list. Not sure what I'm doing wrong here
  • C++: Is it better to store a console output in a macro?
  • C++ - Exception in Constructor
  • AVX: matrix dot vector, but ignore diagonal
  • Pointer To Pointer passed by reference
  • Why is this operator< overload function invisible to STL algorithms?
  • What is the correct algorithm to perform double-float division?
  • In the case of using a std::unique_ptr to automatically deallocate memory upon exiting a scoped block, why not just use
  • C++: Iterating over a string vector and using the index for putenv
  • OpenCL Matrix Multiplication Using std::vector
  • template template parameter deduction: three different compilers three different behaviors
  • C++ pull a card from deck
  • File reading with and without new line
  • store strings in stable memory in c++
  • Why is static_cast used in QT's official document
  • iterator .end() from std::list returns "0xcdcdcdcdcdcdcdcd" but .begin() as expected
  • Is std::sqrt the same as sqrt in C++
  • Iterate through std::initializer_list
  • Codeblocks c++ code doesn't run in VS 19 (vector subscript out of range)
  • Why erase on std::vector promote iterator
  • how to destroy an object in C++
  • How to create Visual Studio 2015 solution from CMake
  • Using concepts for checking if a type T has a field F
  • constructor giving error: no matching function for call to
  • search top n% of a vector member C++
  • Is this reinterpret_cast problematic in principle, and/or in practice?
  • What is the following error doing? I do not see any error with the bounds
  • Two index's of an array have same memory adress
  • how do i avoid integer division in c++?
  • Setting value to enum
  • Properties of a pointer to a zero length array
  • Why the output is different how ever the formula is the same?
  • Restarting from the beginning using do while loops
  • Error: invalid initialization of reference of type
  • how to avoid to use memcpy to create a string
  • Copying the vector elements into std::array
  • Is there any class pointers in Perl in order to access member variables and functions?
  • Why the static variable is not set to 1000
  • Why can't a destructor have reference qualifiers?
  • How to print binary tree in horizontal way?
  • Comparison behavior of ' <' operator
  • Constructors in C++ Language
  • Why displayed value of b , c and y is different from my trace?
  • Undefined reference to `fftw_init_threads' while installing pHash library
  • Reading remapped hdd sectors
  • shadow
    Privacy Policy - Terms - Contact Us © voile276.org