C: Difference between revisions
imported>Mic92 add pkg-config |
imported>Mic92 add cmake example |
||
Line 145: | Line 145: | ||
<syntaxHighlight lang=console> | <syntaxHighlight lang=console> | ||
[nix-shell:~] echo $PKG_CONFIG_PATH | [nix-shell:~] $ echo $PKG_CONFIG_PATH | ||
/nix/store/ypg1r7c8m0rkim7by4ikn68xc88bi53j-cryptsetup-2.0.6-dev/lib/pkgconfig:/nix/store/ypg1r7c8m0rkim7by4ikn68xc88bi53j-cryptsetup-2.0.6-dev/lib/pkgconfig | /nix/store/ypg1r7c8m0rkim7by4ikn68xc88bi53j-cryptsetup-2.0.6-dev/lib/pkgconfig:/nix/store/ypg1r7c8m0rkim7by4ikn68xc88bi53j-cryptsetup-2.0.6-dev/lib/pkgconfig | ||
[nix-shell:~] | [nix-shell:~] $ pkg-config --cflags libcryptsetup | ||
-I/nix/store/ypg1r7c8m0rkim7by4ikn68xc88bi53j-cryptsetup-2.0.6-dev/include | -I/nix/store/ypg1r7c8m0rkim7by4ikn68xc88bi53j-cryptsetup-2.0.6-dev/include | ||
</syntaxHighlight> | |||
== cmake == | |||
Similar to `pkg-config` `cmake` relies on the <code>$CMAKE_PREFIX_PATH</code> to finds its modules (files ending in <code>.cmake</code>). Also see this example: | |||
<syntaxHighlight lang=nix> | |||
with import <nixpkgs> {}; | |||
stdenv.mkDerivation { | |||
name = "env"; | |||
nativeBuildInputs = [ cmake ]; | |||
buildInputs = [ zeromq ]; | |||
} | |||
</syntaxHighlight> | |||
<syntaxHighlight lang=console> | |||
$ nix-shell | |||
[nix-shell:~] $ echo $CMAKE_PREFIX_PATH' | |||
/nix/store/lw4xr0x2p6xyfgbk961lxh8vnnx7vn2r-cmake-3.12.1:/nix/store/j4x44bjjgwy7hm7lazj8xnr9mnlfiksh-patchelf-0.9:/nix/store/isg8rxaxkijl9x3hr2gzsf8pqfnqxg3k-gcc-wrapper-7.4.0:/nix/store/lwdkm354f3zzsvkf7pqmnc8w6r164b42-binutils-wrapper-2.30:/nix/store/biz7v9g4g6yrnp2h8wfn01d6pk3bj2m1-zeromq-4.3.0:/nix/store/lw4xr0x2p6xyfgbk961lxh8vnnx7vn2r-cmake-3.12.1:/nix/store/j4x44bjjgwy7hm7lazj8xnr9mnlfiksh-patchelf-0.9:/nix/store/isg8rxaxkijl9x3hr2gzsf8pqfnqxg3k-gcc-wrapper-7.4.0:/nix/store/lwdkm354f3zzsvkf7pqmnc8w6r164b42-binutils-wrapper-2.30:/nix/store/biz7v9g4g6yrnp2h8wfn01d6pk3bj2m1-zeromq-4.3.0 | |||
[nix-shell:~] cat >CMakeLists.txt <<EOF | |||
cmake_minimum_required(VERSION 2.8) | |||
project(helloworld) | |||
add_executable(helloworld hello.c) | |||
find_package (ZeroMQ) | |||
EOF | |||
[nix-shell:~] $ echo 'int main {}' > hello.c | |||
[nix-shell:~] $ cmake . | |||
</syntaxHighlight> | </syntaxHighlight> |