Closed xkungfu closed 2 years ago
cmake_minimum_required(VERSION 3.21) project(dataframetest) set(CMAKE_CXX_STANDARD 17)
include_directories("I:/CXXlibs/DATAFRAME/DataFrame-2022-01-18/cmakeinstalled/include") include_directories("I:/CXXlibs/DATAFRAME/DataFrame-2022-01-18/cmakeinstalled/lib")
set(CMAKE_PREFIX_PATH I:/CXXlibs/DATAFRAME/DataFrame-2022-01-18/cmakeinstalled/lib/cmake/DataFrame) find_package(DataFrame REQUIRED)
add_executable(hello_world hello_world.cc)
target_link_libraries(hello_world PRIVATE DataFrame::DataFrame)
I found the problem. this version works ok.
sorry for naive question.
np, I am also not a cmake expert. @SpaceIm might be able to provide better suggestions
maybe there are some problem in my code, but I don't know. hope @SpaceIm to give a better one. thank you.
Yes, basic usage of CMake while using find_package()
in your own CMakeLists to discover properly installed external libs:
cmake_minimum_required(VERSION 3.21)
project(dataframetest)
set(CMAKE_CXX_STANDARD 17)
find_package(DataFrame REQUIRED CONFIG)
add_executable(hello_world hello_world.cc)
target_link_libraries(hello_world PRIVATE DataFrame::DataFrame)
then configure and build your project with CMake (assume MinGW on Windows here):
mkdir build
cd build
cmake .. -G "MinGW Makefiles" -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH="<path/to/installed/externalib1>;<path/to/installed/externalib2>;...;<path/to/installed/externalibN>"
cmake --build .
So yes here just populate CMAKE_PREFIX_PATH
with root path of DataFrame install location (or the path of the folder of DataFrameConfig.cmake, it also works, the idea is that CMake must be able to see DataFrameConfig.cmake
through find_package()
).
Do not hardcode CMAKE_PREFIX_PATH
in your CMakeLists, inject it externally since it's completly specific to your local machine (some IDE provide user config files to set CMake variables to inject, it's very convenient, you can also use a CMakePresets.json I think, an advanced solution, see for example https://www.qt.io/blog/new-features-in-cmake-3.19).
CMAKE_PREFIX_PATH
is required only for libraries installed in non-standard location on your system (it's OS specific for CMake, see CMake documentation), and indeed usually you don't want to install external libs for local dev in system location.
Yes, basic usage of CMake while using
find_package()
in your own CMakeLists to discover properly installed external libs:cmake_minimum_required(VERSION 3.21) project(dataframetest) set(CMAKE_CXX_STANDARD 17) find_package(DataFrame REQUIRED CONFIG) add_executable(hello_world hello_world.cc) target_link_libraries(hello_world PRIVATE DataFrame::DataFrame)
then configure and build your project with CMake (assume MinGW on Windows here):
mkdir build cd build cmake .. -G "MinGW Makefiles" -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH="<path/to/installed/externalib1>;<path/to/installed/externalib2>;...;<path/to/installed/externalibN>" cmake --build .
So yes here just populate
CMAKE_PREFIX_PATH
with root path of DataFrame install location (or the path of the folder of DataFrameConfig.cmake, it also works, the idea is that CMake must be able to seeDataFrameConfig.cmake
throughfind_package()
). Do not hardcodeCMAKE_PREFIX_PATH
in your CMakeLists, inject it externally since it's completly specific to your local machine (some IDE provide user config files to set CMake variables to inject, it's very convenient, you can also use a CMakePresets.json I think, an advanced solution, see for example https://www.qt.io/blog/new-features-in-cmake-3.19).
CMAKE_PREFIX_PATH
is required only for libraries installed in non-standard location on your system (it's OS specific for CMake, see CMake documentation), and indeed usually you don't want to install external libs for local dev in system location.
very clear and detailed explanation. I learned a very useful new knowledge. thanks a lot!
I have installed DataFrame by below steps:
and the installed files like below:
I think I can use DataFrame now. but how to write my first cmakelists.txt?
I tried write one like below, it is to be sure it would not work, because I am a newbie and have not any clue.
can you tell me how to modify this to work? and why there isn't a dll file?
thanks!
windows 10 mingw8.0.0 gcc 9.3.1 qt 5.15.2