Skip to content

Instantly share code, notes, and snippets.

@jcfr
Last active September 2, 2015 17:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jcfr/11233992 to your computer and use it in GitHub Desktop.
Save jcfr/11233992 to your computer and use it in GitHub Desktop.
Illustrate issue with file(INSTALL ....) function on MacOSX
cmake_minimum_required(VERSION 2.8.6)
file(WRITE "${CMAKE_SOURCE_DIR}/foo.cpp"
"
class foo
{
public:
foo(){}
~foo(){}
};
")
set(CMAKE_INSTALL_PREFIX "${CMAKE_SOURCE_DIR}/install" CACHE PATH "" FORCE)
project(foo)
set(CMAKE_BUILD_WITH_INSTALL_RPATH ON)
add_library(foo SHARED foo.cpp)
install(TARGETS foo EXPORT PythonTargets
ARCHIVE DESTINATION archive
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin
)
@jcfr
Copy link
Author

jcfr commented Apr 23, 2014

To reproduce:

CMAKE=/path/to/cmake
mkdir foo && cd foo
curl -O https://gist.githubusercontent.com/jcfr/11233992/raw/8bd21a4aeedb3ae0ba83454a38d3145cf2d93148/CMakeLists.txt
mkdir build && cd build
"$CMAKE" ../ && make install
make install
make install

On linux, using CMake 2.8.11.2 or CMake 3.0.0-rc4 the output is:

$ "$CMAKE" ../ && make install
[...]
Install the project...
-- Install configuration: ""
-- Installing: /home/jchris/Downloads/foo/install/lib/libfoo.so
$ make install 
[100%] Built target foo
Install the project...
-- Install configuration: ""
-- Up-to-date: /home/jchris/Downloads/foo/install/lib/libfoo.so
$ make install 
[100%] Built target foo
Install the project...
-- Install configuration: ""
-- Up-to-date: /home/jchris/Downloads/foo/install/lib/libfoo.so

OK: Running make install multiple times in a row always output Up-to-date: /path/to/libfoo.so

On MacOSX 10.8, using CMake 2.8.11.2 or CMake 3.0.0-rc4 the output is:

$ "$CMAKE" ../ && make install
[…]
-- Build files have been written to: /Volumes/Dashboards/Experimental/foo/build
Scanning dependencies of target foo
[100%] Building CXX object CMakeFiles/foo.dir/foo.cpp.o
Linking CXX shared library libfoo.dylib
[100%] Built target foo
Install the project...
-- Install configuration: ""
-- Installing: /Volumes/Dashboards/Experimental/foo/install/lib/libfoo.dylib
$ make install
[100%] Built target foo
Install the project...
-- Install configuration: ""
-- Up-to-date: /Volumes/Dashboards/Experimental/foo/install/lib/libfoo.dylib
$ make install
[100%] Built target foo
Install the project...
-- Install configuration: ""
-- Installing: /Volumes/Dashboards/Experimental/foo/install/lib/libfoo.dylib

NOT OK: Running make install multiple times in a row outputs Installing: /path/to/libfoo.dylib

In the context of _superbuild_ project this is an issue because it cause dependent project to recompile and/or relink if not needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment