Compiler can't find ZLIB even though it is present - cmake

I have the following settings in CLion 2020.1:
I have the following lines in my CMakeLists.txt file:
set(ZLIB_LIBRARY "C:\\Program Files (x86)\\GnuWin32")
set(ZLIB_INCLUDE_DIR "C:\\Program Files (x86)\\GnuWin32\\include")
find_package(ZLIB REQUIRED)
find_package (ZLIB)
if (ZLIB_FOUND)
include_directories(${ZLIB_INCLUDE_DIR})
endif (ZLIB_FOUND)
And, the compiler generates the following error:
C:\Users\pc\CLionProjects\myproject\src\utils/io_utils.hh(8,10): fatal error: 'zlib.h' file not found
#include <zlib.h>
^~~~~~~~
11 warnings and 1 error generated.
NMAKE : fatal error U1077: 'C:\PROGRA~1\LLVM\bin\clang-cl.exe' : return code '0x1'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.28.29910\bin\HostX64\x64\nmake.exe"' : return code '0x2'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.28.29910\bin\HostX64\x64\nmake.exe"' : return code '0x2'
Stop.
How can I correct this?

You only need the following line:
find_package(ZLIB REQUIRED)
# To use zlib:
add_executable(main main.cpp)
target_link_libraries(main PRIVATE ZLIB::ZLIB)
Then, at the command line, pass "-DCMAKE_PREFIX_PATH=C:/Program Files (x86)/GnuWin32" as an argument to the CMake configure step. CMAKE_PREFIX_PATH may also be set as an environment variable and is formatted like your system's PATH env-var (so ; separators on Windows and : elsewhere).
The variable CMAKE_PREFIX_PATH is consulted for a list of sysroots by the find_* commands. The directories in this variable should contain subdirectories like include, lib, bin, etc. Read more about the CMake search procedure here: https://cmake.org/cmake/help/latest/command/find_package.html#search-procedure
So you can see exactly what I did from the x64 Native Tools Command Prompt for VS 2019:
D:\>dir "C:\Program Files (x86)\GnuWin32"
Volume in drive C has no label.
Volume Serial Number is B854-7CB4
Directory of C:\Program Files (x86)\GnuWin32
05/26/2021 11:40 AM <DIR> .
05/26/2021 11:40 AM <DIR> ..
05/26/2021 11:40 AM <DIR> bin
05/26/2021 11:40 AM <DIR> contrib
05/26/2021 11:40 AM <DIR> doc
05/26/2021 11:40 AM <DIR> include
05/26/2021 11:40 AM <DIR> lib
05/26/2021 11:40 AM <DIR> man
05/26/2021 11:40 AM <DIR> manifest
05/26/2021 11:40 AM <DIR> uninstall
0 File(s) 0 bytes
10 Dir(s) 204,769,185,792 bytes free
D:\>dir "C:\Program Files (x86)\GnuWin32\lib"
Volume in drive C has no label.
Volume Serial Number is B854-7CB4
Directory of C:\Program Files (x86)\GnuWin32\lib
05/26/2021 11:40 AM <DIR> .
05/26/2021 11:40 AM <DIR> ..
07/20/2005 08:52 AM 77,534 libz.a
07/20/2005 08:50 AM 43,738 libz.dll.a
07/20/2005 08:50 AM 6,656 zlib-bcc.lib
07/20/2005 08:46 AM 1,868 zlib.def
07/20/2005 08:50 AM 14,778 zlib.lib
5 File(s) 144,574 bytes
2 Dir(s) 204,769,185,792 bytes free
D:\>mkdir test
D:\>cd test
D:\test>notepad CMakeLists.txt
D:\test>type CMakeLists.txt
cmake_minimum_required(VERSION 3.20)
project(test)
find_package(ZLIB REQUIRED)
D:\test>cmake -S . -B build "-DCMAKE_PREFIX_PATH=C:/Program Files (x86)/GnuWin32"
-- Building for: Visual Studio 16 2019
-- Selecting Windows SDK version 10.0.18362.0 to target Windows 10.0.19042.
-- The C compiler identification is MSVC 19.28.29915.0
-- The CXX compiler identification is MSVC 19.28.29915.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.28.29910/bin/Hostx64/x64/cl.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:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.28.29910/bin/Hostx64/x64/cl.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found ZLIB: C:/Program Files (x86)/GnuWin32/lib/zlib.lib (found version "1.2.3")
-- Configuring done
-- Generating done
-- Build files have been written to: D:/test/build
It absolutely does find ZLIB like this.

Related

why can't wsl be called from cmake scripts?

I have bash scripts that generate c++ files and I would like to call them from an add_custom_command() in cmake. On windows, I'd like to call the bash script through wsl (windows subsytem for linux). cmake configures fine (finding wsl.exe), but on build it complains that:
'C:\Windows\System32\wsl.exe' is not recognized as an internal or external command,
Here is a simple cmake script to recreate. It succeeds in a linux environment (including wsl), but fails in the native windows environment.
cmake_minimum_required(VERSION 3.7)
project(WhyNotWSL)
set(source ${CMAKE_SOURCE_DIR}/Input/main.cpp)
set(target generated.cpp )
if (WIN32)
find_program(WSL wsl)
message("WSL is ${WSL}")
set (command ${WSL} cp ${source} ${target})
else()
set (command cp ${source} ${target})
endif()
message("command is ${command}")
add_custom_target( ${target} )
add_custom_command(
OUTPUT ${target}
COMMAND ${command}
DEPENDS ${source}
COMMENT "Generated ${target}"
)
add_custom_target(p ALL
DEPENDS ${target}
)
add_executable(hello ${target})
The following output is from cmake configure:
-- Building for: Visual Studio 16 2019
-- Selecting Windows SDK version 10.0.18362.0 to target Windows 10.0.18363.
-- The C compiler identification is MSVC 19.27.29110.0
-- The CXX compiler identification is MSVC 19.27.29110.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Professional/VC/Tools/MSVC/14.27.29110/
bin/Hostx64/x64/cl.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:/Program Files (x86)/Microsoft Visual Studio/2019/Professional/VC/Tools/MSVC/14.27.2911
0/bin/Hostx64/x64/cl.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
**WSL is C:/Windows/System32/wsl.exe**
**command is C:/Windows/System32/wsl.exe;cp;D:/Development/CMakeWSLTest/Input/main.cpp;generated.cpp**
-- Configuring done
-- Generating done
-- Build files have been written to: D:/Development/CMakeWSLTest/BUILD
And the following is the output from cmake build
Microsoft (R) Build Engine version 16.7.0+b89cb5fde for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.
Checking Build System
Building Custom Rule D:/Development/CMakeWSLTest/CMakeLists.txt
Building Custom Rule D:/Development/CMakeWSLTest/CMakeLists.txt
Generated generated.cpp
'C:\Windows\System32\wsl.exe' is not recognized as an internal or external command,
operable program or batch file.
For the record, the following works from a DOS shell:
>C:\Windows\System32\wsl.exe cp ../Input/main.cpp generated.cpp
Try giving HINTS to find_program() and point to C:\Windows\Sysnative
Something like this:
if (WIN32)
find_program(WSL wsl HINTS C:/Windows/Sysnative)
message("WSL is ${WSL}")
set (command ${WSL} cp ${source} ${target})
else()
set (command cp ${source} ${target})
endif()
Rationale here: https://superuser.com/a/1528297/2201 but basicly, this could be caused by your cmake buil. find_program() finds executable with absolute path that then should be different when it actually gets called during the build, it should actually point the binary from another location due to inherited build type of parent process of your build.
Maybe..

CMake define new target by string processing existing $<TARGET_FILE>

I"m trying to modernize an older CMake script that essentially does the following to generate a libtool file:
get_target_property(target_location ${target} LOCATION)
get_filename_component(target_we ${target_location} NAME_WE)
get_target_property(target_deps ${target} LT_DEPENDENCY_LIBS)
# ...
# Get a bunch more properties...
# ...
set(la_target ${PROJECT_BINARY_DIR}/${target_we}.la)
# ...
# Do a bunch of file(WRITE...) file(APPEND...) etc
# ...
install(FILES ${la_target} DESTINATION ${CMAKE_INSTALL_PREFIX}/lib)
You cannot get the LOCATION property from a target in modern cmake, and I can't figure out how to do get_filename_component() on a $ generator.
Using the generator in an add_custom_command() COMMAND statement only allows one line, so I can't set variables to do all the necessary get_target_property()/file(WRITE...) processing.
Alternatively I can add a COMMAND cmake -P script.cmake to run a script which can do all the string processing but can't define or reference targets, so I appear to be stuck.
EDIT: I'm using the Makefile generator, on macOS, the target in question is a shared library that's generated in the same project.
EDIT2: The error is:
The LOCATION property may not be read from target "mytarget".
Use the target name directly with add_custom_command, or use
the generator expression $<TARGET_FILE>, as appropriate.
You can to it like this:
first use file command to expand generator expressions and render a level-2 template
... which is going to be rendered at build time by configure_file
Here is a sample project:
cmake_minimum_required(VERSION 3.10)
project(location-test VERSION 0.0.1 LANGUAGES CXX)
add_executable(foo foo.cc)
file(GENERATE OUTPUT blah.la.in INPUT blah.la.in.in)
configure_file(render-variables.cmake.in render-variables.cmake #ONLY)
add_custom_command(
OUTPUT "${PROJECT_BINARY_DIR}/blah.la"
COMMAND "${CMAKE_COMMAND}"
-DPROJECT_BINARY_DIR="${PROJECT_BINARY_DIR}"
-DPROJECT_NAME="${PROJECT_NAME}"
-DPROJECT_VERSION="${PROJECT_VERSION}"
-P "${PROJECT_BINARY_DIR}/render-variables.cmake"
MAIN_DEPENDENCY "${PROJECT_BINARY_DIR}/blah.la.in"
DEPENDS "${PROJECT_BINARY_DIR}/render-variables.cmake"
)
add_custom_target(
make-la-la-la ALL
DEPENDS "${PROJECT_BINARY_DIR}/blah.la"
)
blah.la.in.in (2-levels of tempaltes %):
# This file going to be rendered by the following pipeline:
# - at CMake execution time it'll expand all generator expressions
# (e.g. $<TARGET_FILE:foo>)
# - at build time, the `render-variables.cmake` script will substitute
# CMake variables (like #PROJECT_NAME# or #PROJECT_VERSION#)
write the template for your real .la file... render-variables.cmake.in is trivial as :
configure_file("${PROJECT_BINARY_DIR}/blah.la.in" "${PROJECT_BINARY_DIR}/blah.la" #ONLY)
And finally a dummy C++ file foo.cc:
#include <iostream>
int main()
{
std::cout << "Hello Africa!\n";
}
Build it!
localtion-sample$ mkdir build/
localtion-sample$ cd build/
localtion-sample/build$ cmake ..
-- The CXX compiler identification is GNU 5.4.0
-- Check for working CXX compiler: /usr/x86_64-pc-linux-gnu/gcc-bin/5.4.0/c++ -- works
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: /tmp/localtion-sample/build
localtion-sample/build$ make
Scanning dependencies of target foo
[ 33%] Building CXX object CMakeFiles/foo.dir/foo.cc.o
[ 66%] Linking CXX executable foo
[ 66%] Built target foo
Scanning dependencies of target make-la-la-la
[100%] Generating blah.la
[100%] Built target make-la-la-la
localtion-sample/build$ ll
total 52K
drwxr-xr-x 6 zaufi zaufi 320 Feb 9 22:35 CMakeFiles/
-rw-r--r-- 1 zaufi zaufi 287 Feb 9 22:35 blah.la
-rw-r--r-- 1 zaufi zaufi 300 Feb 9 22:35 blah.la.in
-rw-r--r-- 1 zaufi zaufi 11K Feb 9 22:35 CMakeCache.txt
-rw-r--r-- 1 zaufi zaufi 1.5K Feb 9 22:35 cmake_install.cmake
-rwxr-xr-x 1 zaufi zaufi 14K Feb 9 22:35 foo
-rw-r--r-- 1 zaufi zaufi 5.0K Feb 9 22:35 Makefile
-rw-r--r-- 1 zaufi zaufi 89 Feb 9 22:35 render-variables.cmake
localtion-sample/build$ cat blah.la
# This file going to be rendered by the following pipeline:
# - at CMake execution time it'll expand all generator expressions
# (e.g. /tmp/localtion-sample/build/foo)
# - at build time, the `render-variables.cmake` script will substitute
# CMake variables (like location-test or 0.0.1)

How to auto generate pkgconfig files from cmake targets

I would like to generate pkgconfig files in cmake from the targets. I started by writing something like this:
function(auto_pkgconfig TARGET)
get_target_property(INCLUDE_DIRS ${TARGET} INTERFACE_INCLUDE_DIRECTORIES)
string(REPLACE "$<BUILD_INTERFACE:" "$<0:" INCLUDE_DIRS "${INCLUDE_DIRS}")
string(REPLACE "$<INSTALL_INTERFACE:" "$<1:" INCLUDE_DIRS "${INCLUDE_DIRS}")
string(REPLACE "$<INSTALL_PREFIX>" "${CMAKE_INSTALL_PREFIX}" INCLUDE_DIRS "${INCLUDE_DIRS}")
file(GENERATE OUTPUT ${TARGET}.pc CONTENT "
Name: ${TARGET}
Cflags: -I$<JOIN:${INCLUDE_DIRS}, -I>
Libs: -L${CMAKE_INSTALL_PREFIX}/lib -l${TARGET}
")
install(FILES ${TARGET}.pc DESTINATION lib/pkgconfig)
endfunction()
This is a simplified version but it basically reads the INTERFACE_INCLUDE_DIRECTORIES properties and processes the INSTALL_INTERFACE of the generator expressions.
This works well as long as the include directories are set before calling auto_pkgconfig, like this:
add_library(foo foo.cpp)
target_include_directories(foo PUBLIC
$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/include>
${OTHER_INCLUDE_DIRS}
)
auto_pkgconfig(foo)
However, sometimes properties are set after the call to auto_pkgconfig, like this:
add_library(foo foo.cpp)
auto_pkgconfig(foo)
target_include_directories(foo PUBLIC
$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/include>
${OTHER_INCLUDE_DIRS}
)
However, this won't properly read the include directories anymore. I would like auto_pkgconfig to run after all the target properties are set. I could use generator expressions for this, by changing auto_pkgconfig to this:
function(auto_pkgconfig TARGET)
file(GENERATE OUTPUT ${TARGET}.pc CONTENT "
Name: ${TARGET}
Cflags: -I$<JOIN:$<TARGET_PROPERTY:${TARGET},INTERFACE_INCLUDE_DIRECTORIES>, -I>
Libs: -L$<TARGET_FILE_DIR:${TARGET}> -l${TARGET}
")
install(FILES ${TARGET}.pc DESTINATION lib/pkgconfig)
endfunction()
However, this will read the BUILD_INTERFACE instead of the INSTALL_INTERFACE. So is there another way to read target properties after they have been set?
According to the CMake documentation, the contents of INSTALL_INTERFACE are only available when calling install(EXPORT). Unless they extend CMake, it will be best to do something else to generate your PkgConfig files. Ideally you would have enough control over your install layout to make this easy.
However, this doesn't mean you can't do what you ask; it's just "Tony the Pony" levels of evil. I actually hesitated to post this. Please don't take this as a recommendation.
The idea is to use install(EXPORT) to have CMake generate the appropriate scripts. Then generate a dummy CMake project that uses the file(GENERATE OUTPUT ...) code you gave above; the dummy project will see the exported, ie. INSTALL_INTERFACE properties.
I initially tried to use install(CODE [[ ... ]]) to do this, but it also sees the $<BUILD_INTERFACE:...> view. I've asked about this on the CMake Discourse.
cmake_minimum_required(VERSION 3.16)
project(example)
# Dummy library for demo
add_library(example SHARED example.cpp)
target_compile_definitions(example
PUBLIC $<BUILD_INTERFACE:BUILD>
$<INSTALL_INTERFACE:INSTALL>)
target_include_directories(example
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/include>)
# Here be dragons...
function(auto_pc TARGET)
file(CONFIGURE OUTPUT "pc.${TARGET}/CMakeLists.txt"
CONTENT [[
cmake_minimum_required(VERSION 3.16)
project(pc_#TARGET#)
find_package(pc_#TARGET# REQUIRED CONFIG)
file(GENERATE OUTPUT #TARGET#.pc
CONTENT [=[
Name: #TARGET#
Cflags: -I$<JOIN:$<TARGET_PROPERTY:INTERFACE_INCLUDE_DIRECTORIES>, -I> -D$<JOIN:$<TARGET_PROPERTY:INTERFACE_COMPILE_DEFINITIONS>, -D>
Libs: -L$<TARGET_FILE_DIR:#TARGET#> -l#TARGET#
]=] TARGET "#TARGET#")
]] #ONLY NEWLINE_STYLE LF)
install(TARGETS ${TARGET} EXPORT pc_${TARGET})
install(EXPORT pc_${TARGET} DESTINATION "_auto_pc" FILE pc_${TARGET}-config.cmake)
file(CONFIGURE OUTPUT "pc.${TARGET}/post-install.cmake"
CONTENT [[
file(REAL_PATH "${CMAKE_INSTALL_PREFIX}" prefix)
set(proj "#CMAKE_CURRENT_BINARY_DIR#/pc.#TARGET#")
execute_process(COMMAND "#CMAKE_COMMAND#" "-Dpc_#TARGET#_DIR=${prefix}/_auto_pc" -S "${proj}" -B "${proj}/build")
file(COPY "${proj}/build/#TARGET#.pc" DESTINATION "${prefix}")
]] #ONLY NEWLINE_STYLE LF)
install(SCRIPT "${CMAKE_CURRENT_BINARY_DIR}/pc.${TARGET}/post-install.cmake")
endfunction()
auto_pc(example)
# Clean up install path
install(CODE [[ file(REMOVE_RECURSE "${CMAKE_INSTALL_PREFIX}/_auto_pc") ]])
This results in the following:
alex#Alex-Desktop:~/test$ cmake -S . -B build
...
-- Configuring done
-- Generating done
-- Build files have been written to: /home/alex/test/build
alex#Alex-Desktop:~/test$ cmake --build build/
...
alex#Alex-Desktop:~/test$ cmake --install build --prefix install
-- Install configuration: ""
-- Installing: /home/alex/test/install/lib/libexample.so
-- Installing: /home/alex/test/install/_auto_pc/pc_example-config.cmake
-- Installing: /home/alex/test/install/_auto_pc/pc_example-config-noconfig.cmake
-- The C compiler identification is GNU 9.3.0
-- The CXX compiler identification is GNU 9.3.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - 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: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: /home/alex/test/build/pc.example/build
alex#Alex-Desktop:~/test$ ls install/
example.pc lib
alex#Alex-Desktop:~/test$ cat install/example.pc
Name: example
Cflags: -I/home/alex/test/install/include -DINSTALL
Libs: -L/home/alex/test/install/lib -lexample
This should make you sad. It makes me sad.
edit: off topic, since here, the pc files are generated manually
pkgconfig template files
motivation:
CMakeLists.txt should be the single source of truth (name, version)
pkgconfig files are about 10 times smaller than cmake files (cmake to pkgconfig is a lossy transformation)
template file: my_package.pc.in
prefix="#CMAKE_INSTALL_PREFIX#"
exec_prefix="${prefix}"
libdir="${prefix}/lib"
includedir="${prefix}/include"
Name: #PROJECT_NAME#
Description: #CMAKE_PROJECT_DESCRIPTION#
Version: #PROJECT_VERSION#
Cflags: -I${includedir}
Libs: -L${libdir} -l#target1#
CMakeLists.txt
cmake_minimum_required(VERSION 3.0)
project(my_library VERSION 1.1.2 LANGUAGES C
DESCRIPTION "example library")
add_library(my_library src/my_library.c)
# generate pc file for pkg-config
set(target1 my_library)
configure_file(my_package.pc.in
lib/pkgconfig/my_package.pc #ONLY)
based on: CMake generate pkg-config .pc
related: exporting targets to cmake files

CMAKE and cross compiling

I have to change sysroot for my cmake. There is rootfs located on my disk in /u02/rootfs.
I created toolchain_rootfs file and added this config into it:
SET(CMAKE_INSTALL_PREFIX "/u02/rootfs")
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSROOT ${CMAKE_INSTALL_PREFIX})
#set(CMAKE_STAGING_PREFIX /home/devel/stage)
set(CMAKE_FIND_ROOT_PATH ${CMAKE_INSTALL_PREFIX})
set(CMAKE_C_COMPILER "${CMAKE_INSTALL_PREFIX}/usr/bin/gcc")
set(CMAKE_CXX_COMPILER "${CMAKE_INSTALL_PREFIX}/usr/bin/c++")
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
###
SET(CMAKE_SKIP_BUILD_RPATH FALSE)
SET(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/usr/lib")
SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/usr/lib")
After that I run cmake with option:
cmake ../myproject/ -DCMAKE_TOOLCHAIN_FILE=/u02/myproject/toolchain_rootfs
And got error like this:
------------ /u02/rootfs/usr/lib
------------ /u02/rootfs/usr/lib
-- The C compiler identification is unknown
-- The CXX compiler identification is GNU 5.4.0
-- Check for working C compiler: /u02/rootfs/usr/bin/gcc
------------ /u02/rootfs/usr/lib
-- Check for working C compiler: /u02/rootfs/usr/bin/gcc -- broken
CMake Error at /usr/share/cmake-3.5/Modules/CMakeTestCCompiler.cmake:61 (message):
The C compiler "/u02/rootfs/usr/bin/gcc" is not able to
compile a simple test program.
It fails with the following output:
Change Dir: /u02/myproject/CMakeFiles/CMakeTmp
Run Build Command:"/usr/bin/make" "cmTC_0e039/fast"
/usr/bin/make -f CMakeFiles/cmTC_0e039.dir/build.make
CMakeFiles/cmTC_0e039.dir/build
make[1]: Entering directory '/u02/myproject_build/CMakeFiles/CMakeTmp'
Building C object CMakeFiles/cmTC_0e039.dir/testCCompiler.c.o
/u02/rootfs/usr/bin/gcc -o
CMakeFiles/cmTC_0e039.dir/testCCompiler.c.o -c
/u02/myproject_build/CMakeFiles/CMakeTmp/testCCompiler.c
/u02/rootfs/usr/bin/../lib/gcc/x86_64-linux-gnu/4.9/cc1:
error while loading shared libraries: libisl.so.10: cannot open shared
object file: No such file or directory
Could you help me please solve this error. I went through cmake manual, set RPATH, but it doesn't work to me. What is wrong?
UDP1:
I've tried to use sysroot, without toolchain like:
SET(CMAKE_INSTALL_PREFIX "/u02/rootfs")
set(CMAKE_SYSROOT ${CMAKE_INSTALL_PREFIX})
set(CMAKE_FIND_ROOT_PATH ${CMAKE_INSTALL_PREFIX})
SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/usr/lib/x86_64-linux-gnu")
CMAKE was passed, but MAKE was failed. I got error:
/u02/rootfs/usr/bin/ar: error while loading shared libraries: libbfd-2.25-system.so: cannot open shared object file: No such file or directory
rootfs has this library.
How to specify PATH to LIBs in rootfs(sysroot)?

Building hello world at the command line using Cmake and Visual Studio Express 2010

I'm new to CMake. I am trying to build a very simple program (hello world) using Visual Studio 2010 Express. In the Visual Studio 2010 Command Prompt I ran the command:
cmake -g "NMake Makefiles" .
This appeared to work.
C:\Users\david\dev\cmake\hello_world>cmake -g "NMake Makefiles" .
-- Building for: Visual Studio 10
-- Check for working C compiler using: Visual Studio 10
-- Check for working C compiler using: Visual Studio 10 -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler using: Visual Studio 10
-- Check for working CXX compiler using: Visual Studio 10 -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Configuring done
-- Generating done
-- Build files have been written to: C:/Users/david/dev/cmake/hello_world
Next, I tried to run nmake, which produced the following error:
C:\Users\david\dev\cmake\hello_world>nmake
Microsoft (R) Program Maintenance Utility Version 10.00.30319.01
Copyright (C) Microsoft Corporation. All rights reserved.
NMAKE : fatal error U1064: MAKEFILE not found and no target specified
Stop.
I cannot see a Makefile inside the project directory, so I guess that's why it is not working, or perhaps CMake uses a non standard name for Makefile's? I'm unsure. I've pasted the contents of the project directory below.
C:\Users\david\dev\cmake\hello_world>dir
Volume in drive C has no label.
Volume Serial Number is 4000-10E9
Directory of C:\Users\david\dev\cmake\hello_world
08/05/2012 01:38 PM <DIR> .
08/05/2012 01:38 PM <DIR> ..
08/05/2012 01:38 PM 28,584 ALL_BUILD.vcxproj
08/05/2012 01:38 PM 735 ALL_BUILD.vcxproj.filters
08/05/2012 01:38 PM 12,871 CMakeCache.txt
08/05/2012 01:38 PM <DIR> CMakeFiles
08/05/2012 01:34 PM 151 CMakeLists.txt
08/05/2012 01:38 PM 1,514 cmake_install.cmake
08/05/2012 01:38 PM 3,150 hello_world.sln
08/05/2012 01:38 PM 36,618 hello_world.vcxproj
08/05/2012 01:38 PM 671 hello_world.vcxproj.filters
08/05/2012 01:37 PM 2,213 hello_world.vpj
08/05/2012 01:37 PM 206 hello_world.vpw
08/05/2012 01:37 PM 134 hello_world.vpwhist
08/05/2012 01:37 PM 106,496 hello_world.vtg
08/05/2012 07:14 AM 118 main.cpp
08/05/2012 01:38 PM 23,914 ZERO_CHECK.vcxproj
08/05/2012 01:38 PM 807 ZERO_CHECK.vcxproj.filters
15 File(s) 218,182 bytes
3 Dir(s) 134,161,678,336 bytes free
The source for my program is:
#include <iostream>
int main(int argc, char* argv[])
{
std::cout << *argv << std::endl;
return 0;
}
My CMakeLists.txt is:
# CMakeLists.txt
# $ cmake -g "NMake Makefiles" .
cmake_minimum_required(VERSION 2.8)
project(hello_world)
add_executable(hello_world main.cpp)
Thanks,