I'm trying to build the Polycode codes using CMake. I followed the instructions in the Build.md file, but I get the following error:
$ cmake -G "Visual Studio 10" ..
No POLYCODE_RELEASE_DIR specified, to C:/Development/Polycode/Release/Windows
DEBUG CMAKE_PREFIX_PATH=C:/Development/Polycode/Release/Windows/Framework/Core/Dependencies;C:/Development/Polycode/Release/Windows/Framework/Modules/Dependencies;C:/Development/Polycode/Release/Windows/Framework/Tools/Dependencies
CMake Error at c:/Program Files (x86)/CMake 2.8/share/cmake-2.8/Modules/FindPackageHandleStandardArgs.cmake:97 (message):
Could NOT find ZLIB (missing: ZLIB_LIBRARY ZLIB_INCLUDE_DIR)
Call Stack (most recent call first):
c:/Program Files (x86)/CMake 2.8/share/cmake-2.8/Modules/FindPackageHandleStandardArgs.cmake:291 (_FPHSA_FAILURE_MESSAGE)
c:/Program Files (x86)/CMake 2.8/share/cmake-2.8/Modules/FindZLIB.cmake:85 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
CMake/PolycodeIncludes.cmake:14 (FIND_PACKAGE)
Core/Contents/CMakeLists.txt:2 (INCLUDE)
-- Configuring incomplete, errors occurred!
I see that it needs ZLIB but, I don't know how to handle this. Shouldn't it download the dependency automatically? I could surely find ZLIB and download it but I don't really want to do this with every single lib it might need. Is there a convenient way to solve this?
It is a two-step build process. First you need to build the dependencies:
cd Dependencies # <---- this will run the next steps in the Dependencies subdirectory of your Polycode repo
mkdir Build
cd Build
cmake -G "Visual Studio 10" ..
This step should install the required libraries. Only then you can you proceed to build Polycode itself
# <---- this build step is run inside your Polycode root directory
mkdir Build
cd Build
cmake -G "Visual Studio 10" ..
Related
I want to use vcpkg in a CMake project in Windows, because I need boost and xerces that are both handled by this package manager.
I've the following CMakeLists.txt:
cmake_minimum_required (VERSION 3.12.0)
project (myproj)
set (CMAKE_PREFIX_PATH ${XERCES_ROOT})
set (Boost_USE_STATIC_LIBS ON)
set (Boost_USE_MULTITHREADED ON)
unset (Boost_INCLUDE_DIR CACHE)
unset (Boost_LIBRARY_DIRS CACHE)
# set (CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/modules)
find_package (Boost COMPONENTS filesystem regex REQUIRED)
find_package (XercesC CONFIG REQUIRED)
set (CMAKE_INCLUDE_CURRENT_DIR ON)
message (STATUS "binary dir is ${CMAKE_BINARY_DIR}")
include_directories (${CMAKE_BINARY_DIR}/${PROJECT_NAME}/)
include_directories (${CMAKE_CURRENT_SOURCE_DIR}/..)
include_directories (${Boost_INCLUDE_DIRS})
include_directories (${XercesC_INCLUDE_DIRS})
set (PROJECT_SRC
code.cpp
)
add_library (${PROJECT_NAME} SHARED ${PROJECT_SRC})
add_dependencies (${PROJECT_NAME} UPDATE_RESOURCES)
target_link_libraries (${PROJECT_NAME} ${Boost_LIBRARIES} XercesC::XercesC)
Boost and xerces-c are installed with vcpkg. Since I'm using Visual Studio Code I'm setting vcpkg variables in settings.json:
"cmake.configureSettings": {
"CMAKE_TOOLCHAIN_FILE" : "some/path/vcpkg/scripts/buildsystems/vcpkg.cmake",
"VCPKG_TARGET_TRIPLET": "x64-windows"
}
When I run che CMake I obtain following errors:
[cmake] CMake Error at C:/Program Files/CMake/share/cmake-3.14/Modules/FindBoost.cmake:2132 (message):
[cmake] Unable to find the requested Boost libraries.
[cmake]
[cmake] Unable to find the Boost header files. Please set BOOST_ROOT to the root
[cmake] directory containing Boost or BOOST_INCLUDEDIR to the directory containing
[cmake] Boost's headers.
[cmake] Call Stack (most recent call first):
[cmake] D:/projects/vcpkg/scripts/buildsystems/vcpkg.cmake:233 (_find_package)
[cmake] src/myroject/CMakeLists.txt:24 (find_package)
[cmake]
[cmake]
[cmake] CMake Error at D:/Projects/vcpkg/installed/x64-windows/share/xercesc/vcpkg-cmake-wrapper.cmake:1 (_find_package):
[cmake] Could not find a package configuration file provided by "XercesC" with any
[cmake] of the following names:
[cmake]
[cmake] XercesCConfig.cmake
[cmake] xercesc-config.cmake
[cmake]
[cmake] Add the installation prefix of "XercesC" to CMAKE_PREFIX_PATH or set
[cmake] "XercesC_DIR" to a directory containing one of the above files. If
[cmake] "XercesC" provides a separate development package or SDK, be sure it has
[cmake] been installed.
[cmake] Call Stack (most recent call first):
[cmake] D:/Projects/vcpkg/scripts/buildsystems/vcpkg.cmake:189 (include)
[cmake] src/ZLA/CMakeLists.txt:25 (find_package)
[cmake]
[cmake]
[cmake] Configuring incomplete, errors occurred!
[cmake] See also "D:/Projects/zla/build/vscode/CMakeFiles/CMakeOutput.log".
[cms-driver] Error during CMake configure: [cmake-server] Configuration failed.
At the moment I've installed xerces with vcpkg commands, while boost is currently not installed, but I was expecting that during the execution of the cmake command, vcpkg will download and build needed build packages.
I've tried also the command line:
cmake -DCMAKE_TOOLCHAIN_FILE=D:/Projects/vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_TARGET_TRIPLET=x64-windows ../
but the result is the same.
What I'm doing wrong? How can I use vcpkg successfully?
In theory it's as simple as (assuming vcpkg as installed in C:/vcpkg as it is for github actions);
Install your "foo" package with vcpkg install foo
Make sure your CMakeLists.txt finds and uses the package with;
find_package(FOO)
# Use these instead of the package doesn't have proper cmake
package support.
# find_path(FOO_INCLUDE_DIRS foo.h)
# find_library(FOO_LIBRARYS foo)
include_directories(${FOO_INCLUDE_DIRS})
target_link_libraries(myprogram ${FOO_LIBRARIES})
Run cmake with
-DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake
But... this didn't work for me until I added --triplet x64-windows to the vcpkg install command.
The DCMAKE_TOOLCHAIN_FILE sets the various CMAKE_(SYSTEM_)?(PREFIX|LIBRARY|INCLUDE|FRAMEWORK)_PATH variables to enable the find_*() cmake functions to work, but note that these paths include the VCPKG_TARGET_TRIPLET. In my case the package install with vcpkg install <foo> defaulted to x86-windows but then invoking cmake with -DCMAKE_TOOLCHAIN_FILE=C:/.... defaulted to x64-windows so it couldn't find the the package.
Currently vcpkg defaults to the older x86 target, but modern Visual Studio (as used by githup actions) defaults to x64. The fix was to install the package with vcpkg -triplet x64-windows install <foo>. It took me way too long going down too many red-herring rabbit holes to discover this.
You need to install the packages beforehand (using vcpkg install ).
(Then you could specify the toolchain as a CMake option:
-DCMAKE_TOOLCHAIN_FILE=C:\path\to\vcpkg\scripts\buildsystems\vcpkg.cmake
but this won't work if you already specify a toolchain, such as when cross-compiling.)
"include" it, instead, to avoid this problem:
Add this line to the project CMakeLists.txt before find_package():
include(/path/to/vcpkg/scripts/buildsystems/vcpkg.cmake)
boost is currently not installed, but I was expecting that during the execution of the cmake command, vcpkg will download and build needed build packages.
This is not the case as far as I know. You need to install the packages you want with vcpkg beforehand for the triplet you plan to use (i.e. x64-windows). You will then need to ensure that the correct triplet is being used when you run CMake (check the VCPKG_TARGET_TRIPLET variable in your CMakeCache.txt). If it's incorrect, you can change it and re-configure using CMake.
Additionally, based on the error output you're getting, it doesn't seem that xerces has been installed properly either using vcpkg. You can check what is installed with vcpkg by running:
vcpkg list --triplet x64-windows
I had the same issue and just solved it either with:
set(CURL_DIR "C:/Libs/vcpkg/installed/x64-windows/share/curl")
or
list(APPEND CMAKE_PREFIX_PATH "C:/Libs/vcpkg/packages/curl_x64-windows/share/curl/")
I installed vcpkg under C:/Libs
I have been struggling for a few days trying to get MySQL C++ Connector to compile on Windows. I have Cygwin installed.
I run the following
set cc=gcc
set cxx=gcc
cmake -G "MinGW Makefiles" -DCMAKE_REQUIRED_FLAGS=-xO4 -DCMAKE_INSTALL_PREFIX=C:\\exports\\Connector -DMYSQL_CONFIG_EXECUTABLE="C:\\Program Files\\MySQL\\MySQL Server 5.7"
But I get the following output:
-- Boost version: 1.61.0
-- BOOST_INCLUDE_DIRS=C:/boost_1_61_0
-- You will link dynamically to the MySQL client library (set with -DMYSQLCLIENT_STATIC_LINKING=<bool>)
-- Searching for dynamic libraries with the base name(s) "libmysql"
CMake Error at FindMySQL.cmake:494 (message):
Could not find the include dir from running "C:\\Program
Files\\MySQL\\MySQL Server 5.7"
Call Stack (most recent call first):
CMakeLists.txt:218 (INCLUDE)
-- Configuring incomplete, errors occurred!
See also "C:/Users/Chris/MySQLConnector/CMakeFiles/CMakeOutput.log".
I don't get why it says it can't find the include directory because I can see it in the path C:\Program Files\MySQL\MySQL Server 5.7\include
I just found out about Openbr and started to install required libraries like OpenCV and QT. I followed these instructions for windows(win10 64bit):
http://openbiometrics.org/docs/install/#windows
but unfortionatly got stuck when executing the following command:
cmake -G "NMake Makefiles" -DBUILD_PERF_TESTS=OFF -DBUILD_TESTS=OFF -DWITH_FFMPEG=OFF -DCMAKE_BUILD_TYPE=Debug ..
with this output:
CMake Error at C:/opencv-2.4.11/build-msvc2013/win-install/OpenCVConfig.cmake:71 (include):
include could not find load file:
C:/opencv-2.4.11/build-msvc2013/win-install/OpenCVModules.cmake
Call Stack (most recent call first):
CMakeLists.txt:87 (find_package)
-- adding C:/openbr/openbr/plugins/classification
-- adding C:/openbr/openbr/plugins/cluster
-- adding C:/openbr/openbr/plugins/cmake
-- adding C:/openbr/openbr/plugins/core
-- importing C:/openbr/openbr/plugins/cuda/module.cmake
-- adding C:/openbr/openbr/plugins/distance
-- adding C:/openbr/openbr/plugins/format
-- adding C:/openbr/openbr/plugins/gallery
-- adding C:/openbr/openbr/plugins/gui
-- adding C:/openbr/openbr/plugins/imgproc
-- adding C:/openbr/openbr/plugins/io
-- adding C:/openbr/openbr/plugins/metadata
-- adding C:/openbr/openbr/plugins/output
-- adding C:/openbr/openbr/plugins/representation
-- adding C:/openbr/openbr/plugins/video
CMake Error at openbr/CMakeLists.txt:52 (add_subdirectory):
The source directory
C:/openbr/openbr/janus
does not contain a CMakeLists.txt file.
CMake Warning at C:/Program Files/CMake/share/cmake-3.6/Modules /InstallRequiredSystemLibraries.cmake:463 (message):
system runtime library file does not exist:
'MSVC12_REDIST_DIR-NOTFOUND/x64/Microsoft.VC120.CRT/msvcp120.dll'
Call Stack (most recent call first):
share/openbr/cmake/InstallDependencies.cmake:135 (include)
openbr/CMakeLists.txt:67 (install_compiler_libraries)
CMake Warning at C:/Program Files/CMake/share/cmake-3.6/Modules/InstallRequiredSystemLibraries.cmake:463 (message):
system runtime library file does not exist:
'MSVC12_REDIST_DIR-NOTFOUND/x64/Microsoft.VC120.CRT/msvcr120.dll'
Call Stack (most recent call first):
share/openbr/cmake/InstallDependencies.cmake:135 (include)
openbr/CMakeLists.txt:67 (install_compiler_libraries)
-- Configuring incomplete, errors occurred!
See also "C:/openbr/build-msvc2013/CMakeFiles/CMakeOutput.log".
There is a project that was developed for linux environment. Now I am trying to build this on windows using CMake.
I keep trying to build the project and always get this error:
CMake Error at C:/Program Files(x86)/CMake/share/cmake-3.3/Modules/FindPackageHandleStandardArgs.cmake:148 (message):
Could NOT find GTest (missing: GTEST_LIBRARY GTEST_INCLUDE_DIR GTEST_MAIN_LIBRARY)
Call Stack (most recent call first):
C:/Program Files(x86)/CMake/share/cmake-3.3/Modules/FindPackageHandleStandardArgs.cmake:388 (_FPHSA_FAILURE_MESSAGE)
C:/Program Files(x86)/CMake/share/cmake-3.3/Modules/FindGTest.cmake:204 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
C:/Users/awy9/git/cmake_modules/modules/SigeoGTest.cmake:21 (find_package)
C:/Users/awy9/git/cmake_modules/modules/SigeoInit.cmake:29 (include)
CMakeLists.txt:12 (include)
How can I set these variables to work on this project now on Windows?
Honestly It's not the best idea to set hardcoded variables like you've done with GTEST_LIBRARY and GTEST_MAIN_LIBRARY.
I had the exact same problem. I was using gtest 1.7.0 on windows and getting the same error.
Turns out "GTest" should be "gtest" (not capitalized).
So the code in my CMakeLists.txt became:
find_package(gtest REQUIRED)
Note that I was using CMake 3.9
EDIT
I would highly recommend following this guide now:
http://crascit.com/2015/07/25/cmake-gtest/
It is by far the best method I have found to use unbuilt gtest and gmock in your cmake project.
UPDATE
#Tsyvarev helped me solving the first problem and I quote him:
This is standard CMake message, when requested package(GTest in your case) is not found. You should install GTest before configuring your project. Or, if you already have installed it into non-standard location, pass this location via GTEST_ROOT variable: cmake -DGTEST_ROOT= ...
As alternative for the passing variable to cmake, you can set environment variable: set GTEST_ROOT=
This solved the problem with the value of GTEST_INCLUDE_DIR, but I still had these errors:
CMake Error at C:/Program Files (x86)/CMake/share/cmake-3.3/Modules/FindPackageH andleStandardArgs.cmake:148 (message): Could NOT find GTest (missing: GTEST_LIBRARY GTEST_MAIN_LIBRARY)
SOLUTION
I figured that on Windows environment some values are different from what the manuals say.
After compiling Gtest, I got two libs: gtest.lib and gtest_main.lib
Then, I set these filepath variables:
GTEST_LIBRARY=C:\Users\awy9\Softwares\Gtest\gtest-1.7.0\Debug\gtest.lib
GTEST_MAIN_LIBRARY=C:\Users\awy9\Softwares\Gtest\gtest-1.7.0\Debug\gtest_main.lib
Now everything is working!
Thank you
I've come up with a similar issue when building my project through GitHub Actions on Windows platform.
Even if I export the CMAKE_PREFIX_PATH to enable the find_package(GTest REQUIRED) to properly find the framework library (Windows is a bit nasty BTW), it continues to fail with Could NOT find GTest (missing: GTEST_LIBRARY GTEST_MAIN_LIBRARY). Note that it correctly fetches the include directory.
After digging a little bit deeper into the issue I realized that on Windows the command cmake --build . --target install without any --config options, builds the library in Debug configuration, contrary to Linux and macOS.
If you are then building your project in Release, e.g. cmake .. -DCMAKE_BUILD_TYPE=Release && cmake --build . --config Release --target install, the find_package(GTest REQUIRED) won't find any GTest library because it searches for the nonexistent Release build.
In this case a better solution is to install GTest in Release mode w.r.t. hardcoding the library paths to fetch the Debug\ directory builds.
I attach also the GitHub Action steps which may be helpful for someone:
steps:
- name: Clone GTest
shell: bash
working-directory: ${{runner.workspace}}
run: git clone https://github.com/google/googletest.git
- name: Create GTest Build Environment
shell: bash
working-directory: ${{runner.workspace}}/googletest
run: cmake -E make_directory build
- name: Configure GTest CMake
shell: bash
working-directory: ${{runner.workspace}}/googletest/build
run: cmake .. -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DCMAKE_CXX_FLAGS=-std=c++11
- name: Install GTest
shell: bash
working-directory: ${{runner.workspace}}/googletest/build
run: cmake --build . --config $BUILD_TYPE --target install || sudo cmake --build . --config $BUILD_TYPE --target install
- name: Export CMAKE_PREFIX_PATH on Windows
shell: bash
if: runner.os == 'Windows'
run: echo '::set-env name=CMAKE_PREFIX_PATH::C:/Program Files (x86)/googletest-distribution'
- name: Checkout
uses: actions/checkout#v2
- ... your project build steps
I am trying to build PODOFO library with CMake using MinGW compiler. It requires some external libraries like zlib, jpeg, openssl and freetype. My cmake command is as follows:
cmake -G "MinGW Makefiles"
-DCMAKE_INCLUDE_PATH=c:\Users\Abhishek\Downloads\freetype-2.3.5-1-bin\include -DCMAKE_LIBRARY_PATH=c:\Users\Abhishek\Downloads\freetype-2.3.5-1-bin\lib
-DCMAKE_INCLUDE_PATH=c:\Users\Abhishek\Downloads\zlib\include -DCMAKE_LIBRARY_PATH=c:\Users\Abhishek\Downloads\zlib\lib -DCMAKE_INCLUDE_PATH=C:\Users\Abhishek\Downloads\openssl-0.9.8h-1-lib\include -DCMAKE_LIBRARY_PATH=c:\Users\Abhishek\Downloads\openssl-0.9.8h-1-lib\lib
-DPODOFO_BUILD_SHARED:BOOL=FALSE ..
Somehow it is not able to find the freetype files. The error I get is as follows:
CMake Error at C:/Program Files (x86)/CMake 2.8/share/cmake-2.8/Modules/FindPackageHandleStandardArgs.cmake:97 (message):
Could NOT find FREETYPE (missing: FREETYPE_LIBRARY FREETYPE_INCLUDE_DIR)
Call Stack (most recent call first):
C:/Program Files (x86)/CMake 2.8/share/cmake-2.8/Modules/FindPackageHandleStan dardArgs.cmake:291
(_FPHSA_FAILURE_MESSAGE)
cmake/modules/FindFREETYPE.cmake:75
(FIND_PACKAGE_HANDLE_STANDARD_ARGS) CMakeLists.txt:372
(FIND_PACKAGE)
-- Configuring incomplete, errors occurred!
One additional point. If I delete the previous CMake build files (cache etc) then it doesn't even find zlib!
I can't understand why this erratic behaviour. Can anyone shed light on this?
When you're configuring, you need to define FREETYPE_INCLUDE_DIR and the other variables for where you keep the libraries it depends on - cmake can't guess these just from your include paths.