I am trying to create a system wide service on Mac using CMake for build and CPack for generate a package. The repository is quite big, so I have created a smaller version to test it. It turns out that I don't know how to pack something that have an absolute path as a destination.
This is the CMake code:
install(PROGRAMS ${CMAKE_BINARY_DIR}/hello
DESTINATION "/var/local/hello"
COMPONENT TS
)
install(PROGRAMS com.hello.world.plist
DESTINATION "/Library/LaunchDaemons/"
COMPONENT TS
)
And this is the output from cpack
mac-mini-2:build melanoholly$ cpack ..
CPack: Create package using productbuild
CPack: Install projects
CPack: - Run preinstall target for: testingPack
CPack: - Install project: testingPack
CMake Error at /Users/salvobit/sandbox/cpack-example-mac-daemon/build/cmake_install.cmake:44 (file):
file cannot create directory: /var/local/hello. Maybe need administrative
privileges.
CMake Error at /Users/salvobit/sandbox/cpack-example-mac-daemon/build/cmake_install.cmake:56 (file):
file INSTALL cannot copy file
"/Users/salvobit/sandbox/cpack-example-mac-daemon/com.hello.world.plist" to
"/Library/LaunchDaemons/com.hello.world.plist".
CPack Error: Error when generating package: testingPack
If I run cpack as root the generated package is empty.
Can somebody give me and idea how to fix this?
I use CMake of version 3.13.0-rc2.
The key to solving this was specifying the CMAKE_INSTALL_PREFIX as that
set(CMAKE_INSTALL_PREFIX "/")
When you do it like that you can install path in /var/ as
install(PROGRAMS <binary>
DESTINATION "../var")
Related
I have Criterion framework (https://github.com/Snaipe/Criterion), I want to build it from source and install to specific directory so headers of criterion should be located in
/usr/include/
and libraries libcriterion.so in /usr/lib64 folder
I use this command to build and install:
mkdir build
cd build
cmake ..
cmake --build .
make install
it installs .so files to /usr/local/ folder, bash command find / -name "*criterion*" shows this:
/usr/local/lib/libcriterion.so
/usr/local/lib/libcriterion.so.3
/usr/local/lib/libcriterion.so.3.1.0
/usr/local/share/pkgconfig/criterion.pc
/usr/local/include/criterion
/usr/local/include/criterion/criterion.h
How can I fix my command so that after installation libcriterion.so was located in /usr/lib64 directory ?
Using CMake command line options does not allow changing the library install location as requested. You could change use the -DCMAKE_INSTALL_PREFIX=... option, but that would affect the include location, as well.
However, since you have access to the source code, you could simply modify the CMakeLists.txt file and set the library install location by adding a command like this:
install(TARGETS ${PROJECT_NAME}
LIBRARY DESTINATION lib64
)
For further details, I may link to the CMake documentation.
By the way: There is no need to create the build directory explicitly, your script could look like this
cmake -H. -Bbuild
cmake --build build
cmake --build build --target install
I am compiling C++ Poco libraries. I do
cmake -DCMAKE_INSTALL_PREFIX=./ -DCMAKE_BUILD_TYPE=Debug ../
make
make install
At make install I get an error
"path/poco/instDir/lib/libPocoEncodingsd.so.60".
Call Stack (most recent call first):
cmake_install.cmake:50 (include)
Makefile:85: recipe for target 'install' failed
make: *** [install] Error
Basically the file libPocoEncodingsd.so.60 is created with make but then make install deletes it.
Why is that?
If I do not run make install the folder inside the installation path is not created and all the *.h files are not copied there.
This happens because:
-DCMAKE_INSTALL_PREFIX=./
means that you are installing over the top of the build directory itself,
with the result that for each filename in the cmake command:
file(INSTALL DESTINATION "${CMAKE_INSTALL_PREFIX}/lib" TYPE SHARED_LIBRARY FILES
"path/poco/instDir/lib/libPocoEncodingsd.so.60"
"path/poco/instDir/lib/libPocoEncodingsd.so"
)
the source and destination files are the same. Cmake preemptively deletes the
destination file to replace it with the source file. Which means it has deleted
the source file. Hence your failure.
This behaviour may be a bug in cmake. On the face of it, if it checks and finds that the
destination file exists and has the same timestamp as the source file, it should consider
the destination file up to date and not attempt to replace it. But I haven't delved into that. Installing on top of your build directory is reasonably classified
under Don't do that.
Conventionally on Unix-like OSes, locally built packages shall be installed to
/usr/local. That's what /usr/local is for. Cmake, like other source package
deployment tools, respects this convention by default. So if you simply run:
cmake -DCMAKE_BUILD_TYPE=Debug ../
make
sudo make install # Or however you run `make install` as root.
then the poco libraries will be installed in /usr/local/lib and the headers
in /usr/local/include/Poco. /usr/local/lib is a default library search path for the
linker and /usr/local/include is a default header search path for the compiler.
If for some reason you don't want to install to the default prefix, then
choose some:
-DCMAKE_INSTALL_PREFIX=/not/in/the/build/dir
and you will avoid this problem.
I have downloaded the latest Haskell Platform(8.0.1 version) for Windows 7, wxWidgets-3.0.2, set all the needed environment variables. I have successfully installed "wxdirect" using "cabal install", but when I try to install "wxc" it fails. Install logs:
C:\wxWidgets-3.0.2\lib\gcc_dll\mswud\..: getDirectoryContents: does not exist
(The system cannot find the path specified.)
cabal: Leaving directory '.'
Where do I need to get that "gcc_dll\mswud\" folder?
P.S Neither Abriline nor Achelanne works for me for some reason.
P.P.S I tried to install this library following Haskell-wiki instructions, but it didn't work complaining about a ton of dependencies.
UPDATE
I tried installing the wxHaskell using Haskell Platform 2014.2.0.0 with Abriline installer. It stopped on building wxc. Logs:
Building wxc
setup.exe: Maybe.fromJust: Nothing
1] Compiling Main ( wxc-0.92.2.0\dist\setup\setup.hs, wxc-0.92.2.0\dist\setup\Main.o )
Linking .\wxc-0.92.2.0\dist\setup\setup.exe ...
The bitness is correct
Configuring wxc-0.92.2.0...
Configuring wxc to build against wxWidgets 3.0.2
cabal: Leaving directory '.\wxc-0.92.2.0'
UPDATE
Extended logs with "cabal install wxc -v3":
http://rgho.st/7BJcHzJTF
From the log it seems that maybe pkg-config is missing. From the platform's built in msys2 run pacman -S pkg-config and install it, see if it works after that.
I've installed it as follows.
Download wxInstall-Achelanne-64-0.1.zip, unzip, and set this folder as the current directory in a terminal
Type
Set WXWIN=%CD%\wxWidgets
Set WXCFG=gcc_dll\mswu
Set PATH=%CD%;%PATH%
cabal unpack wxdirect
cabal install ./wxdirect-xxx
(where xxx is e.g. 0.92.3).
Find the file wxdirect.exe and put it in the current directory.
Rename the file wxWdigets/include/wx/setup_redirect.h to wxWdigets/include/wx/setup.h
Type
cabal unpack wxc
cabal install ./wxc-xxx
Find the file wxc.dll and put it in the DLLs folder.
Put the folders DLLs and wxWidgets\lib\gcc_dll in your search path.
Now you can install wxcore and wx.
I am trying to build Boost.Python according to the instructions on the official website.
My OS is Windows 7 64-bit, the compiler is MSVC11, the boost is 1.54.
=================== Install Boost ==================
To install basic Boost, I downloaded the boost library from its website, unzip it to my local disk. The path is C:\local\boost_1_54_0.
=============== Install Boost.Python ===============
I then find that Boost.Python need to be built separately. So I followed the Boost.Python instruction.
=============== Install Boost.Build ================
And at stage 3.1.2, Boost.Build is required. So I, again, followed the steps and install Boost.Build at C:\local\boost_1_54_0\BoostBuild, and added C:\local\boost_1_54_0\BoostBuild\bin into the Path enviroment variable.
Then I am stuck at stage 3.1.3 and 3.1.4, where the instruction says
3.cd into the libs/python/example/quickstart/ directory of your Boost installation, which contains a small example project.
4.Invoke bjam. Replace the “stage“ argument from the example invocation from section 5 of the Getting Started Guide with “test,“ to
build all the test targets. Also add the argument “--verbose-test” to
see the output generated by the tests when they are run.
On Windows, your bjam invocation might look something like:
C:\boost_1_34_0\…\quickstart> bjam toolset=msvc --verbose-test test
I've typed the command line that the instruction told me and I am sure that I am in the right directory. However, there is no bjam or b2 in the quickstart folder (they are at the root direcroty of Boost and C:\local\boost_1_54_0\BoostBuild\bin).
I even tried to copy these two files to the quickstart folder, but doesn't work at all.
I am not very familiar with the Windows management mechanism, thus am not sure if the Path is the key to my question. I guess after I added the bin folder to the PATH, the OS will automatically link my bjam toolset=msvc --verbose-test test to the bjam in the C:\local\boost_1_54_0\BoostBuild\bin folder?
Can anyone help me with this? :)
1.) Unzip boost_1_55_0.zip
2.) Prepare to use the Boost Library Binaries
Go to the boost_1_55_0 root directory and open a command prompt and type following commands:
Bootstrap
3.) Find user-config.jam:
Type following in the command prompt:
ECHO %HOMEDRIVE%%HOMEPATH%
4.) If the user-config.jam is in your homedrive directory please change it there as followed:
ATTENTION:
The .jam language rates a “whitespace” as a separation of arguments!
# -------------------
# MSVC configuration.
# -------------------
# Configure msvc (default version, searched for in standard locations and PATH).
# using msvc ;
# Configure specific msvc version (searched for in standard locations and PATH).
using msvc : 10.0 : C:\\app\\tools\\MSVisualStudio2010\\VC\\bin\\cl.exe ;
….
# ---------------------
# Python configuration.
# ---------------------
# Configure specific Python version.
# using python : 3.1 : /usr/bin/python3 : /usr/include/python3.1 : /usr/lib ;
using python
: 2.5 # Version
: C:\\app\\tools\\Python25\\python.exe # Python Path
: C:\\app\\tools\\Python25\\include # include path
: C:\\app\\tools\\Python25\\libs # lib path(s)
: <define>BOOST_ALL_NO_LIB=1
;
5.) Build the Libraries AFTER configuration!!
Go to the boost_1_55_0 root directory and open a command prompt and type following commands:
.\b2
6.) Copy the user-config.jam to \boost_1_55_0\libs\python\example\tutorial
7.) Go further to \boost_1_55_0\stage\lib\
Rename libboost_python-vc100-mt-gd-1_55.lib to boost_python-vc100-mt-gd-1_55.lib and copy it to
\boost_1_55_0\libs\python\example\tutorial
8.) Now you should have all of these files in the \boost_1_55_0\libs\python\example\tutorial directory
hello.cpp
hello.py
user-config.jam
Jamroot
boost_python-vc100-mt-gd-1_55.lib
bjam.exe
9.) Open a command prompt in \boost_1_55_0\libs\python\example\tutorial
And type following command:
bjam
10.) After successful building..
You should have this file in the directory:
hello_ext.dll
rename this file to:
hello_ext.pyd
Let be a library A that I compile with CMake. I also want to distribute it via a package (e.g. RPM).
Where should my package install the files AConfig.cmake and AConfigVersion.cmake ?
In /usr/share/cmake/Modules on Linux ?
You should find what you need here:
http://www.cmake.org/Wiki/CMake/Tutorials/Packaging
With the relevant portion of the text:
Consider a project "Foo" that installs the following files:
<prefix>/include/foo-1.2/foo.h
<prefix>/lib/foo-1.2/libfoo.a
It may also provide a CMake package configuration file
<prefix>/lib/foo-1.2/foo-config.cmake
The config files need the be in your install tree. Only the FindXXX.cmake file should go in the modules directory.