NetCDF-C++: How to build it? - c++

I would like to use the NetCDF API in my C++ projects.
In the offical web site documentation, I saw that this C++ interface have a compilation dependency of NetCDF-C library.
I already downloaded binary NetCDF-C installer (called netCDF4.7.1-NC4-DAP-64.exe) from the offical website (link here) installed it and add the installed folder to my PATH.
C:\Program Files\netCDF 4.7.1\
So I tested it in the Windows console runing: ncdump.exe ...and all works good!
Now I cloned the NetCDF-CXX4 repository (link here) and tried to compile it, but I got a lot of CMake errors.
My system is:
Windows 10 x64
Visual Studio 2019 Enterprise
CMake 3.14.4
NetCDF-CXX 4.3.1
What I did
Inside the cloned NetCDF-CXX4 folder, I created a folder called "build".
Inside the build folder I typed: cmake ..
Here is the console error
cmake ..
-- Building for: Visual Studio 16 2019
-- The C compiler identification is MSVC 19.23.28105.4
-- The CXX compiler identification is MSVC 19.23.28105.4
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/VC/Tools/MSVC/14.23.28105/bin/Hostx64/x64/cl.exe
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/VC/Tools/MSVC/14.23.28105/bin/Hostx64/x64/cl.exe -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/VC/Tools/MSVC/14.23.28105/bin/Hostx64/x64/cl.exe
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/VC/Tools/MSVC/14.23.28105/bin/Hostx64/x64/cl.exe -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found bash: C:/Program Files/Git/usr/bin/bash.exe
-- Looking for nc_use_parallel_enabled in netcdf
CMake Error at C:/Users/lamar/Desktop/netcdf-cxx4-4.3.1/build/CMakeFiles/CMakeTmp/CMakeLists.txt:17 (add_executable):
Target "cmTC_7cc31" links to target "hdf5::hdf5-shared" but the target was
not found. Perhaps a find_package() call is missing for an IMPORTED
target, or an ALIAS target is missing?
CMake Error at C:/Users/lamar/Desktop/netcdf-cxx4-4.3.1/build/CMakeFiles/CMakeTmp/CMakeLists.txt:17 (add_executable):
Target "cmTC_7cc31" links to target "hdf5::hdf5_hl-shared" but the target
was not found. Perhaps a find_package() call is missing for an IMPORTED
target, or an ALIAS target is missing?
CMake Error at C:/Users/lamar/Desktop/netcdf-cxx4-4.3.1/build/CMakeFiles/CMakeTmp/CMakeLists.txt:17 (add_executable):
Target "cmTC_7cc31" links to target "hdf5::hdf5-shared" but the target was
not found. Perhaps a find_package() call is missing for an IMPORTED
target, or an ALIAS target is missing?
CMake Error at C:/Users/lamar/Desktop/netcdf-cxx4-4.3.1/build/CMakeFiles/CMakeTmp/CMakeLists.txt:17 (add_executable):
Target "cmTC_7cc31" links to target "hdf5::hdf5_hl-shared" but the target
was not found. Perhaps a find_package() call is missing for an IMPORTED
target, or an ALIAS target is missing?
CMake Error at C:/Users/lamar/Desktop/netcdf-cxx4-4.3.1/build/CMakeFiles/CMakeTmp/CMakeLists.txt:17 (add_executable):
Target "cmTC_7cc31" links to target "hdf5::hdf5-shared" but the target was
not found. Perhaps a find_package() call is missing for an IMPORTED
target, or an ALIAS target is missing?
CMake Error at C:/Users/lamar/Desktop/netcdf-cxx4-4.3.1/build/CMakeFiles/CMakeTmp/CMakeLists.txt:17 (add_executable):
Target "cmTC_7cc31" links to target "hdf5::hdf5_hl-shared" but the target
was not found. Perhaps a find_package() call is missing for an IMPORTED
target, or an ALIAS target is missing?
CMake Error at C:/Users/lamar/Desktop/netcdf-cxx4-4.3.1/build/CMakeFiles/CMakeTmp/CMakeLists.txt:17 (add_executable):
Target "cmTC_7cc31" links to target "hdf5::hdf5-shared" but the target was
not found. Perhaps a find_package() call is missing for an IMPORTED
target, or an ALIAS target is missing?
CMake Error at C:/Users/lamar/Desktop/netcdf-cxx4-4.3.1/build/CMakeFiles/CMakeTmp/CMakeLists.txt:17 (add_executable):
Target "cmTC_7cc31" links to target "hdf5::hdf5_hl-shared" but the target
was not found. Perhaps a find_package() call is missing for an IMPORTED
target, or an ALIAS target is missing?
CMake Error at C:/Users/lamar/Desktop/netcdf-cxx4-4.3.1/build/CMakeFiles/CMakeTmp/CMakeLists.txt:17 (add_executable):
Target "cmTC_7cc31" links to target "hdf5::hdf5-shared" but the target was
not found. Perhaps a find_package() call is missing for an IMPORTED
target, or an ALIAS target is missing?
CMake Error at C:/Users/lamar/Desktop/netcdf-cxx4-4.3.1/build/CMakeFiles/CMakeTmp/CMakeLists.txt:17 (add_executable):
Target "cmTC_7cc31" links to target "hdf5::hdf5_hl-shared" but the target
was not found. Perhaps a find_package() call is missing for an IMPORTED
target, or an ALIAS target is missing?
CMake Error at C:/Program Files/cmake/share/cmake-3.14/Modules/CheckLibraryExists.cmake:67 (try_compile):
Failed to generate test project build system.
Call Stack (most recent call first):
CMakeLists.txt:382 (CHECK_LIBRARY_EXISTS)
-- Configuring incomplete, errors occurred!
See also "C:/Users/lamar/Desktop/netcdf-cxx4-4.3.1/build/CMakeFiles/CMakeOutput.log".
What I have to do to build the NetCDF-CXX4 static/dynamic libraries in my system?

Related

Movesense can't generate ninja files according to documentation

C++ development and related evironments are not something I use so I might be missing som knowledge in this area.
I want to do som sensor programming and want to deploy the example-project to get it working and then write my own code to extend it there after.
I've managed running projects in the Simulator using Visual Studio 2017.
But couldn't get building example-project using Visual Studio C++ Compiler working so installed MinGW firstly: https://sourceforge.net/projects/mingw/
But following the instructions at https://movesense.com/docs/esw/getting_started/#example-project
I can't run the create ninja files step correctly.
I get this error running the command:
cmake -G "Ninja" -DCMAKE_TOOLCHAIN_FILE=../movesense-device-lib/MovesenseCoreLib/toolchain/gcc-nrf52.cmake -DMOVESENSE_CORE_LIBRARY=../movesense-device-lib/MovesenseCoreLib ../ -DCMAKE_BUILD_TYPE=Debug ../
CMake Warning:
Ignoring extra path from command line:
"C:/Development/movesense-device-lib/MovesenseCoreLib/toolchain/gcc-nrf52.cmake"
CMake Warning:
Ignoring extra path from command line:
"../movesense-device-lib/MovesenseCoreLib"
CMake Warning (dev) in CMakeLists.txt:
No project() command is present. The top-level CMakeLists.txt file must
contain a literal, direct call to the project() command. Add a line of
code such as
project(ProjectName)
near the top of the file, but after cmake_minimum_required().
CMake is pretending there is a "project(Project)" command on the first
line.
This warning is for project developers. Use -Wno-dev to suppress it.
-- The C compiler identification is GNU 6.3.0
-- The CXX compiler identification is GNU 6.3.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/MinGW/bin/gcc.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/MinGW/bin/c++.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- The ASM compiler identification is GNU
-- Found assembler: C:/MinGW/bin/gcc.exe
CMake Error at CMakeLists.txt:13 (include):
include could not find requested file:
C:/Development/builddir//MovesenseFromStaticLib.cmake
Adding the MovesenseFromStaticLib.cmake manually doesn't work either gives me these errors:
Ignoring extra path from command line:
"C:/Development/movesense-device-lib/MovesenseCoreLib/toolchain/gcc-nrf52.cmake"
CMake Warning:
Ignoring extra path from command line:
"../movesense-device-lib/MovesenseCoreLib"
CMake Warning (dev) in CMakeLists.txt:
No project() command is present. The top-level CMakeLists.txt file must
contain a literal, direct call to the project() command. Add a line of
code such as
project(ProjectName)
near the top of the file, but after cmake_minimum_required().
CMake is pretending there is a "project(Project)" command on the first
line.
This warning is for project developers. Use -Wno-dev to suppress it.
-- The C compiler identification is GNU 6.3.0
-- The CXX compiler identification is GNU 6.3.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/MinGW/bin/gcc.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/MinGW/bin/c++.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- The ASM compiler identification is GNU
-- Found assembler: C:/MinGW/bin/gcc.exe
CMake Error at builddir/MovesenseFromStaticLib.cmake:29 (include):
include could not find requested file:
C:/Development/builddir/app-build/toolchain-setup.cmake
Call Stack (most recent call first):
CMakeLists.txt:13 (include)
CMake Error at builddir/MovesenseFromStaticLib.cmake:30 (include):
include could not find requested file:
C:/Development/builddir/app-build/prolog.cmake
Call Stack (most recent call first):
CMakeLists.txt:13 (include)
CMake Error at builddir/MovesenseFromStaticLib.cmake:32 (include):
include could not find requested file:
C:/Development/builddir/app-build/platform/.cmake
Call Stack (most recent call first):
CMakeLists.txt:13 (include)
CMake Error at builddir/MovesenseFromStaticLib.cmake:33 (include):
include could not find requested file:
C:/Development/builddir/app-build/compiler/.cmake
Call Stack (most recent call first):
CMakeLists.txt:13 (include)
CMake Error at builddir/MovesenseFromStaticLib.cmake:40 (INIT_SIMULATOR_ENVIRONMENT):
Unknown CMake command "INIT_SIMULATOR_ENVIRONMENT".
Call Stack (most recent call first):
CMakeLists.txt:13 (include)
-- Configuring incomplete, errors occurred!
Like Tsyvarev mentioned should be space after -D, but still get:
cmake -G "Ninja" -D CMAKE_TOOLCHAIN_FILE=../movesense-device-lib/MovesenseCoreLib/toolchain/gcc-nrf52.cmake -D MOVESENSE_CORE_LIBRARY=../movesense-device-lib/MovesenseCoreLib ../ -D CMAKE_BUILD_TYPE=Debug ../
CMake Warning (dev) in CMakeLists.txt:
No project() command is present. The top-level CMakeLists.txt file must
contain a literal, direct call to the project() command. Add a line of
code such as
project(ProjectName)
near the top of the file, but after cmake_minimum_required().
CMake is pretending there is a "project(Project)" command on the first
line.
This warning is for project developers. Use -Wno-dev to suppress it.
-- The C compiler identification is unknown
-- The CXX compiler identification is unknown
CMake Error in CMakeLists.txt:
The CMAKE_C_COMPILER:
arm-none-eabi-gcc
is not a full path and was not found in the PATH.
Tell CMake where to find the compiler by setting either the environment
variable "CC" or the CMake cache entry CMAKE_C_COMPILER to the full path to
the compiler, or to the compiler name if it is in the PATH.
CMake Error in CMakeLists.txt:
The CMAKE_CXX_COMPILER:
arm-none-eabi-gcc
is not a full path and was not found in the PATH.
Tell CMake where to find the compiler by setting either the environment
variable "CXX" or the CMake cache entry CMAKE_CXX_COMPILER to the full path
to the compiler, or to the compiler name if it is in the PATH.
The CMakeLists.txt look like this:
cmake_minimum_required(VERSION 3.4)
enable_language(C CXX ASM)
if(NOT DEFINED MOVESENSE_CORE_LIBRARY)
# Give error that user must provide path to movescount-core library
message(FATAL_ERROR "Path to movesense-core library not set. Add -DMOVESENSE_CORE_LIBRARY=<path_to_core_lib> to cmake command line")
endif()
if(NOT IS_ABSOLUTE ${MOVESENSE_CORE_LIBRARY})
set(MOVESENSE_CORE_LIBRARY ${CMAKE_BINARY_DIR}/${MOVESENSE_CORE_LIBRARY})
endif()
include(${MOVESENSE_CORE_LIBRARY}/MovesenseFromStaticLib.cmake REQUIRED)
Any help on what is the issue and how to solve it?
You are trying to build the project on the MinGW terminal in windows instead of the Docker container as described in the documentation:
https://movesense.com/docs/esw/getting_started/#build-commands-real-hw
Starting Movesense 2.0 the docker environment is the only supported build environment.
Full disclosure: I work for the Movesense

How to link "ShaderWriter" with vcpkg and cmake?

I want to link the library ShaderWriter with CMake and vcpkg.
However, when I have the following two lines in my CMakeLists.txt:
find_package(ShaderWriter CONFIG REQUIRED)
target_link_libraries(Game PRIVATE sdw::ShaderAST sdw::CompilerGlsl sdw::CompilerHlsl sdw::ShaderWriter)
I receive the following cmake error:
[CMake] CMake Error at D:/Dokumente/Repositories/vcpkg/scripts/buildsystems/vcpkg.cmake:534 (_add_executable):
[CMake] Target "Game" links to target "sdw::CompilerGlsl" but the target was not
[CMake] found. Perhaps a find_package() call is missing for an IMPORTED target, or
[CMake] an ALIAS target is missing?
[CMake] Call Stack (most recent call first):
[CMake] Game/CMakeLists.txt:4 (add_executable)
[CMake] CMake Error at D:/Dokumente/Repositories/vcpkg/scripts/buildsystems/vcpkg.cmake:534 (_add_executable):
[CMake] Target "Game" links to target "sdw::CompilerHlsl" but the target was not
[CMake] found. Perhaps a find_package() call is missing for an IMPORTED target, or
[CMake] an ALIAS target is missing?
[CMake] Call Stack (most recent call first):
[CMake] Game/CMakeLists.txt:4 (add_executable)
[CMake] -- Generating done
What am I missing? After installing ShaderWriter, It suggests only the two lines I inserted.
The usage suggested by vcpkg is misleading.
In share/shaderwriter there are two *Config.cmake files:
ShaderWriterConfig.cmake and SdwCompilersConfig.cmake. The targets mentioned in your error output come from SdwCompilersConfig.cmake hence you should add both find_package(ShaderWriter CONFIG REQUIRED) and find_package(SdwCompilers CONFIG REQUIRED) calls.

CMake not finding boost libraries from conan

So I'm trying to get my cmake to work with conan/boost. For this I have a simple conan file:
from conans import ConanFile
class Boost_Conan_Cmake_MinimalConfig(ConanFile):
name = "Boost_Conan_Cmake_MinimalConfig"
generators = "cmake"
options = {"shared": [True, False], "st": [True, False]}
default_options = {"shared": False, "st": True}
def requirements(self):
self.requires("boost/1.69.0#_/_")
self.options["boost"].shared = False
I call this via conan install . --build=missing. This runs perfectly fine and installs boost without problems. When investigating into the folder you can also find all the boost libraries etc.
Next comes my CMakeList.txt. It's pretty straight forward:
cmake_minimum_required(VERSION 3.0)
# CHANGE PROJECT NAME, SOURCES AND DEPENDANT TARGETS
project(boost-conan CXX)
include(conanbuildinfo.cmake)
conan_basic_setup()
set(TARGET_NAME ${PROJECT_NAME})
set(${TARGET_NAME}_SRC src/main.cpp)
find_package(Boost 1.69.0 REQUIRED COMPONENTS filesystem)
add_executable(test "src/main.cpp")
target_include_directories(test PUBLIC $(Boost_INCLUDE_DIRS))
target_link_libraries(test Boost::filesystem)
However, when I try to run this CMake file I get an error:
-- Building for: Visual Studio 16 2019
-- Selecting Windows SDK version 10.0.18362.0 to target Windows 10.0.19041.
-- The CXX compiler identification is MSVC 19.26.28805.0
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual
Studio/2019/Community/VC/Tools/MSVC/14.26.28801/bin/Hostx64/x64/cl.exe
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual
Studio/2019/Community/VC/Tools/MSVC/14.26.28801/bin/Hostx64/x64/cl.exe -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Conan: Adjusting output directories
-- Conan: Using cmake global configuration
-- Conan: Adjusting default RPATHs Conan policies
-- Conan: Adjusting language standard
-- Current conanbuildinfo.cmake directory: D:/boost-conan
-- WARN: CONAN_COMPILER variable not set, please make sure yourself that your compiler and version
matches your declared settings
CMake Error at C:/Program Files/CMake/share/cmake-
3.16/Modules/FindPackageHandleStandardArgs.cmake:146 (message):
Could NOT find Boost (missing: filesystem) (found suitable version
"1.69.0", minimum required is "1.69.0")
Call Stack (most recent call first):
C:/Program Files/CMake/share/cmake-3.16/Modules/FindPackageHandleStandardArgs.cmake:393(_FPHSA_FAILURE_MESSAGE)
C:/Program Files/CMake/share/cmake-3.16/Modules/FindBoost.cmake:2179 (find_package_handle_standard_args)
CMakeLists.txt:11 (find_package)
-- Configuring incomplete, errors occurred!
See also "D:/boost-conan/CMakeFiles/CMakeOutput.log".
Does anyone have an idea how to fix this? Or does anyone have an idea why this error occurs? The Error message alone doesn't really help...
Thanks in advance!

Remove CMP0020 error in CMake 3.14.0 when using Qt

I've the following CMakeFiles.txt
cmake_minimum_required (VERSION 3.14.0)
project (awfviewer)
message (STATUS "Building project ${PROJECT_NAME}")
set (Boost_USE_STATIC_LIBS ON)
set (Boost_USE_MULTITHREADED ON)
unset (Boost_INCLUDE_DIR CACHE)
unset (Boost_LIBRARY_DIRS CACHE)
set (CMAKE_INCLUDE_CURRENT_DIR ON)
set (CMAKE_AUTOMOC ON)
set (CMAKE_AUTORCC ON)
find_package (Boost COMPONENTS program_options filesystem REQUIRED)
find_package (Qt5Core REQUIRED)
include_directories (${CMAKE_SOURCE_DIR}/src ${CMAKE_CURRENT_SOURCE_DIR} ${Boost_INCLUDE_DIRS})
set (PROJECT_SRC
main.cpp
)
set (PROJECT_QRC
${CMAKE_CURRENT_SOURCE_DIR}/Resources/awfviewer.qrc
)
add_executable (${PROJECT_NAME} ${PROJECT_SRC} ${PROJECT_QRC})
target_link_libraries(${PROJECT_NAME} ${Boost_LIBRARIES})
qt5_use_modules (${PROJECT_NAME} Widgets Svg)
Building with CMake 3.14.0 I obtain following output:
[cmake] The C compiler identification is MSVC 19.16.27030.1
[cmake] The CXX compiler identification is MSVC 19.16.27030.1
[cmake] Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/BuildTools/VC/Tools/MSVC/14.16.27023/bin/Hostx86/x64/cl.exe
[cmake] Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/BuildTools/VC/Tools/MSVC/14.16.27023/bin/Hostx86/x64/cl.exe -- works
[cmake] Detecting C compiler ABI info
[cmake] Detecting C compiler ABI info - done
[cmake] Detecting C compile features
[cmake] Detecting C compile features - done
[cmake] Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/BuildTools/VC/Tools/MSVC/14.16.27023/bin/Hostx86/x64/cl.exe
[cmake] Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/BuildTools/VC/Tools/MSVC/14.16.27023/bin/Hostx86/x64/cl.exe -- works
[cmake] Detecting CXX compiler ABI info
[cmake] Detecting CXX compiler ABI info - done
[cmake] Detecting CXX compile features
[cmake] Detecting CXX compile features - done
[cmake] Building project awfviewer
[cmake] Boost version: 1.69.0
[cmake] Found the following Boost libraries:
[cmake] program_options
[cmake] filesystem
[cmake] Boost version: 1.69.0
[cmake] Boost version: 1.69.0
[cmake] Building project connectiontest
[cmake] Looking for pthread.h
[cmake] Looking for pthread.h - not found
[cmake] Found Threads: TRUE
[cmake] Boost version: 1.69.0
[cmake] Found the following Boost libraries:
[cmake] unit_test_framework
[cmake] log
[cmake] system
[cmake] date_time
[cmake] log_setup
[cmake] filesystem
[cmake] thread
[cmake] regex
[cmake] chrono
[cmake] atomic
[cmake] Building project awfconnectiontest
[cmake] Boost version: 1.69.0
[cmake] Found the following Boost libraries:
[cmake] unit_test_framework
[cmake] log
[cmake] system
[cmake] date_time
[cmake] log_setup
[cmake] filesystem
[cmake] thread
[cmake] regex
[cmake] chrono
[cmake] atomic
[cmake] Configuring done
[cmake] CMake Warning (dev) in src/AWFViewer/CMakeLists.txt:
[cmake] Policy CMP0020 is not set: Automatically link Qt executables to qtmain
[cmake] target on Windows. Run "cmake --help-policy CMP0020" for policy details.
[cmake] Use the cmake_policy command to set the policy and suppress this warning.
[cmake] This warning is for project developers. Use -Wno-dev to suppress it.
[cmake]
[cmake] CMake Warning (dev) in src/AWFViewer/CMakeLists.txt:
[cmake] Policy CMP0020 is not set: Automatically link Qt executables to qtmain
[cmake] target on Windows. Run "cmake --help-policy CMP0020" for policy details.
[cmake] Use the cmake_policy command to set the policy and suppress this warning.
[cmake] This warning is for project developers. Use -Wno-dev to suppress it.
[cmake]
[cmake] CMake Warning (dev) in thirdparty/WRibbon/src/WRibbon/CMakeLists.txt:
[cmake] Policy CMP0020 is not set: Automatically link Qt executables to qtmain
[cmake] target on Windows. Run "cmake --help-policy CMP0020" for policy details.
[cmake] Use the cmake_policy command to set the policy and suppress this warning.
[cmake] This warning is for project developers. Use -Wno-dev to suppress it.
[cmake]
[cmake] CMake Warning (dev) in src/AWFViewer/CMakeLists.txt:
[cmake] Policy CMP0020 is not set: Automatically link Qt executables to qtmain
[cmake] target on Windows. Run "cmake --help-policy CMP0020" for policy details.
[cmake] Use the cmake_policy command to set the policy and suppress this warning.
[cmake] This warning is for project developers. Use -Wno-dev to suppress it.
[cmake]
[cmake] CMake Warning (dev) in thirdparty/WRibbon/src/WRibbon/CMakeLists.txt:
[cmake] Policy CMP0020 is not set: Automatically link Qt executables to qtmain
[cmake] target on Windows. Run "cmake --help-policy CMP0020" for policy details.
[cmake] Use the cmake_policy command to set the policy and suppress this warning.
/// repeat many times
[cmake]
[cmake] Generating done
[cmake] CMake Warning:
[cmake] Manually-specified variables were not used by the project:
[cmake]
[cmake] CMAKE_EXPORT_COMPILE_COMMANDS
[cmake]
[cmake]
[build] Starting build
/// Build starts here
I've read the output of cmake --help-policy CMP0020:
Automatically link Qt executables to qtmain target on Windows.
CMake 2.8.10 and lower required users of Qt to always specify a link
dependency to the qtmain.lib static library manually on Windows.
CMake 2.8.11 gained the ability to evaluate generator expressions
while determining the link dependencies from IMPORTED targets. This
allows CMake itself to automatically link executables which link to Qt
to the qtmain.lib library when using IMPORTED Qt targets. For
applications already linking to qtmain.lib, this should have little
impact. For applications which supply their own alternative WinMain
implementation and for applications which use the QAxServer library,
this automatic linking will need to be disabled as per the
documentation.
The OLD behavior for this policy is not to link executables to
qtmain.lib automatically when they link to the QtCore IMPORTED target.
The NEW behavior for this policy is to link executables to qtmain.lib
automatically when they link to QtCore IMPORTED target.
This policy was introduced in CMake version 2.8.11. CMake version
3.14.0 warns when the policy is not set and uses OLD behavior. Use
the cmake_policy command to set it to OLD or NEW explicitly.
.. note::
The ``OLD`` behavior of a policy is
``deprecated by definition``
and may be removed in a future version of CMake.
But I don't understand what I'm doing wrong by using Qt in the CMake project.
How should I modify the CMakelists.txt in order to use Qt properly and remove the warning?
# Jepessen, I tried to replicate your problem and I got your same error. I bypassed the problem by using an older version of CMake, 3.1 in this case, and also I specified that I wanted to use C++ language using CMAKE_CXX_FLAGS with specific directions -std=c++11. You are totally correct about the documentation you mentioned.
When CMake needs to know the behavior to use it checks if this is specified within the project, and if it is not, then CMake sets the OLD behavior as default. As a consequence of that the warning pops up asking the user to take care of that.
I usually try not to include cmake_policy(policy #) as the majority of them are for older versions and consequently some functionalities could be deprecated and substituted by new versions. Of course there could be situations where cmake_policy(SET CMP<####> NEW) and cmake_policy(SET CMP<####> OLD) have to be specifically addressed.
Below is the working code (it compiles on my computer):
cmake_minimum_required (VERSION 3.1)
project (awfviewer)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
set(CMAKE_INCLUDE_CURRENT_DIR ON)
message (STATUS "Building project ${PROJECT_NAME}")
set (Boost_USE_STATIC_LIBS ON)
set (Boost_USE_MULTITHREADED ON)
unset (Boost_INCLUDE_DIR CACHE)
unset (Boost_LIBRARY_DIRS CACHE)
set (CMAKE_INCLUDE_CURRENT_DIR ON)
set (CMAKE_AUTOMOC ON)
set (CMAKE_AUTORCC ON)
find_package (Boost COMPONENTS program_options filesystem REQUIRED)
find_package (Qt5Core REQUIRED)
include_directories (${CMAKE_SOURCE_DIR}/src ${CMAKE_SOURCE_DIR}/main ${CMAKE_CURRENT_SOURCE_DIR} ${Boost_INCLUDE_DIRS})
set (PROJECT_SRC)
set (PROJECT_MAIN
main.cpp
)
add_executable (${PROJECT_NAME} ${PROJECT_SRC})
target_link_libraries(${PROJECT_NAME} ${Boost_LIBRARIES})
In this case the only thing I didn't replicate was creating a QRC file but it does not matter for the small example. Usually CMake is able to recognize and accept older versions of CMake itself given the newer version.
The print screen of what I created in this case is
I hope this could be useful for your project

CMake cannot find requested Boost libraries

Now that I've looked through other peoples solutions for several hours and could not find quite the right answer for my problem I would like to bring my specific problem to you. :)
I am trying to build vsomeip with CMake. For that I previously built boost 1.55, however, I get the following errors in CMake:
The C compiler identification is MSVC 19.0.24215.1
The CXX compiler identification is MSVC 19.0.24215.1
Check for working C compiler: C:/Program Files (x86)/Microsoft Visua Studio 14.0/VC/bin/cl.exe
Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/cl.exe -- works
Detecting C compiler ABI info
Detecting C compiler ABI info - done
Detecting C compile features
Detecting C compile features - done
Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/cl.exe
Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/cl.exe -- works
Detecting CXX compiler ABI info
Detecting CXX compiler ABI info - done
Detecting CXX compile features
Detecting CXX compile features - done
Setting build type to 'RelWithDebInfo' as none was specified.
Looking for pthread.h
Looking for pthread.h - not found
Found Threads: TRUE
CMake Error at C:/Program Files/CMake/share/cmake-3.12/Modules/FindBoost.cmake:2025 (message):
Unable to find the requested Boost libraries.
Boost version: 1.55.0
Boost include path: C:/Program Files/boost/boost_1_55_0
Could not find the following static Boost libraries:
boost_system
boost_thread
boost_log
Some (but not all) of the required Boost libraries were found. You may
need to install these additional Boost libraries. Alternatively, set
BOOST_LIBRARYDIR to the directory containing Boost libraries or BOOST_ROOT
to the location of Boost.
Call Stack (most recent call first):
CMakeLists.txt:99 (find_package)
Boost was not found!
Could NOT find PkgConfig (missing: PKG_CONFIG_EXECUTABLE)
Systemd was not found, watchdog disabled!
using MSVC Compiler
Predefined unicast address: 127.0.0.1
Predefined diagnosis address: 0x00
Predefined routing application: vsomeipd
Could NOT find Doxygen (missing: DOXYGEN_EXECUTABLE)
CMake Warning at CMakeLists.txt:335 (message):
Doxygen is not installed. Documentation can not be built.
CMake Warning at CMakeLists.txt:374 (message):
asciidoc is not installed. Readme can not be built.
GTEST_ROOT is not defined. For building the tests the variable
GTEST_ROOT has to be defined. Tests can not be built.
Configuring incomplete, errors occurred!
See also "D:/Desktop/BACHELORARBEIT/vsomeip/build/CMakeFiles /CMakeOutput.log".
See also "D:/Desktop/BACHELORARBEIT/vsomeip/build/CMakeFiles/CMakeError.log".
It cannot find the static Boost libraries. Now, I've tried playing around with the CMakeList.txt and here is the part of it that would be supposed to handle the linking:
# Boost
set(BOOST_INCLUDE_DIR C:/Program Files/Boost/boost_1_55_0)
set(BOOST_LIBRARYDIR C:/Program Files/Boost/boost_1_55_0/stage/libs)
set(Boost_USE_STATIC_LIBS ON)
set(Boost_USE_MULTITHREADED ON)
find_package( Boost 1.55 COMPONENTS system thread log REQUIRED )
include_directories( ${Boost_INCLUDE_DIR} )
if(Boost_FOUND)
if(Boost_LIBRARY_DIR)
MESSAGE( STATUS "Boost_LIBRARY_DIR not empty using it: ${Boost_LIBRARY_DIR}" )
else()
if(BOOST_LIBRARYDIR)
MESSAGE( STATUS "Boost_LIBRARY_DIR empty but BOOST_LIBRARYDIR is set setting Boost_LIBRARY_DIR to: ${BOOST_LIBRARYDIR}" )
set(Boost_LIBRARY_DIR ${BOOST_LIBRARYDIR})
endif()
endif()
else()
MESSAGE( STATUS "Boost was not found!")
endif()
I have also tried using a newer boost version (1.67) with same results. Any help will be dearly appreciated!
Check if your compiled libraries are in the following directory:
C:/Program Files/Boost/boost_1_55_0/stage/libs
If not, set your lib folder directory path:
set(BOOST_LIBRARYDIR path_to_lib_directory)
As #Tsyvarev suggested I used set(Boost_DEBUG ON) to trace the exact locations and files that CMake was looking for and the discovered several problems:
1.) Setting the path to "C:/Program Files/Boost/boost_1_55_0"
causes problems, because of the space in the path
2.) It searched for the libraries covering multiple formats like: boost_thread-vc141-mt-gd-x32-1_55.lib.
However, when I built boost with incorrect parameters, so my libs were built like this:
libboost_thread-vc-mt-1_55.lib, which is not of the correct format.
3.) Unfortunately adding other options when building boost, e.g.:
b2 toolset=msvc-14.1 address-model=32 --build-type=complete
caused other errors. Also building boost_1_67_0 manually worked for me at all.
My solution to the problem was to simply take one of the third-party download( https://dl.bintray.com/boostorg/release/1.67.0/binaries/). This way all the libraries were built correctly and I had no trouble linking to them.