CPack doesn't include mfc100.dll - dll

I thought this directive includes the necessary runtime libraries in my NSIS installer generated by CPack:
include(InstallRequiredSystemLibraries)
But it doesn't. When I install my application with this installer on another PC, it complains that mfc100.dll is missing - it isn't included in the installer. Trying to set MFC linking to static leads to a myriad of errors when compiling, so this isn't an option.
Can I manually figure out the path where I can get mfc100.dll from and copy it to the install directory in the CMake script, so that it will be included in the NSIS installer? Are there other options to include it?

The trick is to tell CPack to include them:
set(CMAKE_INSTALL_MFC_LIBRARIES ON)
include(InstallRequiredSystemLibraries)

Related

Why won't find_library find libgmp

I'm trying to build a cmake project, and the repo I have been given has the lines
find_library(gmp gmp)
if(NOT gmp)
message(FATAL_ERROR "gmp not found")
endif()
which cause CMake configuration to fail.
I have been told this CMake works on Redhat Enterprise Linux 7.3.
I have also been told this repo should build in any Linux environment with the correct libraries installed, and an Ubuntu environment has been specifically referenced.
I am building in Debian 9.4.0, I have installed gmp, libgmp.so is located at /usr/lib/x86_64-linux-gnu/openssl-1.0.2/engines/libgmp.so
and I also have a libgmp.so.10 at /usr/lib/x86_64-linux-gnu/libgmp.so.10.
So, to recap, I have been handed a repo I have been told builds, but it does not build, it fails at this specific step, and I can't get google to give me any relevant results on how to fix the issue/what I am doing wrong.
libgmp is installed, but the development libraries are not.
Cmake find_libraries looks for the files required for software development, and while the libgmp package is installed, the libgmp-dev package is not.
Install libgmp-dev.
CMake doesn't search "so-version" files:
If find_library is called for "gmp" library name, CMake searches libgmp.so file, but not libgmp.so.10 one.
Normally, the library file without so-version is just a soft link to the newest so-version file. If your Linux distro doesn't create such link, you may create it manually:
ln -s libgmp.so libgmp.so.10
If you want CMake to find /usr/lib/x86_64-linux-gnu/openssl-1.0.2/engines/libgmp.so file, which is not under directory normally searched by CMake, you need to hint CMake about it. E.g. with PATHS option:
find_library(gmp gmp PATHS "/usr/lib/x86_64-linux-gnu/openssl-1.0.2/engines")

cpack cmake windows "ABSOLUTE path INSTALL DESTINATION forbidden"

I am trying to use cpack with cmake and nsis to generate an installer which add the .exe files generated to the environment variable.
I have a main cmakelist.txt
in which I add subdirectory with add_subdirectory( each subdirectory has a cmakelist.txt.
in the main subdirectory at the end for now I added:
SET(CPACK_NSIS_MODIFY_PATH ON)
SET(CPACK_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION OFF)
INCLUDE(CPack)
and in each "sub"cmakelist.txt
I added :
SET(CPACK_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION OFF)
INCLUDE(CPack)
I have this error:
CPack: Create package using NSIS
CPack: Install projects
CPack: - Install project: MIALSRTK
CMake Error at D:... ABSOLUTE path INSTALL DESTINATION forbidden (by caller):
(this is why I tried: SET(CPACK_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION OFF) but it hasn't change anything).
I tried to run as administrator as well.
I also tried the solution here: CPack NSIS, generate installer for Windows
but if(pack) doesn't seem to works. it goes into the else(pack) part (i used the command message to see where it goes).
Do you have any idea on how to solve this problem ?
Setting variable CPACK_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION to OFF cannot disable checking for NSIS CPack generator:
Some CPack generators, like NSIS, enforce this internally.
With NSIS generator you have no other way than using relative install paths.
Construction if(pack) will work only if you pass pack variable explicitly to cmake. There is no implicit way for CMakeLists.txt to detect, whether it is run under CPack.

How to install library from add_subdirectory in current directory

I'm using LuaDist's LuaJIT and I'm trying to add it to my CMake project via add_subdirectory. It seems to build the solution, but it doesn't actually make the libs. How do I tell the sub_directory to also make and install? Do I need to edit that project's CMake, or can I do it from my CMake project (preferred)?
Additionally, when I build and install LuaJIT seperately it installs to C:\Program Files (x86). I don't want that when I build it from my project. I want it to install to my projects \lib\LuaJIT directory (or basically build in place).
# lua
message( STATUS "Building Lua")
include_directories(${PROJECT_SOURCE_DIR}/libs/luajit/src)
add_subdirectory(${PROJECT_SOURCE_DIR}/libs/luajit)

find SFML with CMake on Windows

I compiled SFML on windows (MinGW) and find myself with a directory structure with bin, include, lib and a cmake/Modules/FindSFML.cmake file.
I can't find how to use SFML in the CMakeLists.txt, whether it is
find_package(SFML REQUIRED)
or
find_package(SFML CONFIG REQUIRED)
All I get when I use cmake is:
CMake Error at CMakeLists.txt:34 (find_package):
Could not find a package configuration file provided by "SFML" with any of
the following names:
SFMLConfig.cmake
sfml-config.cmake
Add the installation prefix of "SFML" to CMAKE_PREFIX_PATH or set
"SFML_DIR" to a directory containing one of the above files. If "SFML"
provides a separate development package or SDK, be sure it has been
installed.
I tried setting manually:
SFML_DIR:PATH=E:/code/libraries/SFML-2.4.0
CMAKE_MODULE_PATH:PATH=E:/code/libraries/SFML-2.4.0
or
CMAKE_MODULE_PATH:PATH=E:/code/libraries/SFML-2.4.0/cmake/modules
But I'm not making any progress.
This is the step by step guide we were provided (picture). When this is done you have to remember that you need to link the librarys to your program, with this line:
target_link_libraries (<Name of project here> sfml-graphics sfml-window sfml-system)
if you want to use audi library in SFML just add sfml-audio at the end and so on.
in debug mode you should have a -dat the end of each library. Like this sfml-graphics-d.
If you do some big change in CMake or changing project you need to add:
-IC:/dev/libs/SFML/include -LC:/dev/libs/SFML/libback again.
(You can add the folder where you want). -Iis for Include folders and -Lis for all lib folders, you need this letter in front of all paths.
If you have problems linking /bin folder up you can drop all the .dll files inside System32 folder(for 64-bit, SysWOW64 for 32-bit).
And remember, have a GW that is matching SFML.
When I got same error in cmake-gui, all I did - added entry with name "SFMLDIR" and value with path to sfml directory.

CMake does not compĂ­le Qt5 generate from buildroot

I generate a tarball with Qt5 using Buildroot 2014.05.
When I uncompressed this files to compile my project using CMake I receive the following error message:
CMake Error at <project> /sysroot/usr/lib/cmake/Qt5Core/Qt5CoreConfig.cmake:27 (message):
The imported target "Qt5::Core" references the file
"<project>/host/usr/bin/qmake"
but this file does not exist. Possible reasons include:
* The file was deleted, renamed, or moved to another location.
* An install or uninstall procedure did not complete successfully.
* The installation package was faulty and contained
"/<project>/sysroot/usr/lib/cmake/Qt5Core/Qt5CoreConfigExtras.cmake"
but not all the files it references.
I'm using the cmake configs under
<project>/sysroot/usr/lib/cmake/
and my CMakeLists.txt
set(CMAKE_PREFIX_PATH <project>/sysroot/usr/lib/cmake/QtWidgets/ )
find_package(Qt5Widgets REQUIRED)
Any suggestion?
Buildroot 2014.05 does not have qmake to install
This part: I generate a tarball with Qt5 using Buildroot does make much sense. What do you mean exactly by this ?
If by this you mean that you tarball'ed the contents of output/host/ (which is the toolchain and all the libraries that you need to build applications for your target), then beware that it is not relocatable. So it has to be installed in the same location as the one it was generated in. So for now, if you want to do this, you should set the BR2_HOST_DIR configuration option to something like /opt/<something>/, and then tarball that up and uncompress it on the other machines where you want to use the toolchain.
It's in our TODO-list to make this relocatable.