toeb / cmakepp

An Enhancement Suite for the CMake Build System
Other
436 stars 37 forks source link

Cmake generation fails when cmakepp.cmake is placed in a read-only directory #97

Open 15knots opened 9 years ago

15knots commented 9 years ago

I installed cmakepp in the cmake modules dir /usr/share/cmake/Modules/, using the rpm under linux. That directory does not allow write access to normal users. drwxr-xr-x 9 root root 15016 12. Mär 21:51 /usr/share/cmake/Modules/

If I add the line include(cmakepp) to my CMakeLists.txt, cmake properly finds cmakepp.

But I get lots errors when I let cmake generate the build scripts:

CMake Error at /usr/share/cmake/Modules/cmakepp.cmake:16892 (file): file Internal CMake error when trying to open file: /usr/share/cmake/Modules/tmp/file_make_temporary_LjZKhAz1k3.tmp for writing. Call Stack (most recent call first): /usr/share/cmake/Modules/cmakepp.cmake:5441 (file_make_temporary) /usr/share/cmake/Modules/cmakepp.cmake:15617 (eval) /usr/share/cmake/Modules/cmakepp.cmake:14673 (string_semicolon_decode) /usr/share/cmake/Modules/cmakepp.cmake:21917 (structured_list_parse) /usr/share/cmake/Modules/cmakepp.cmake:33436 (config_setup) CMakeLists.txt:35 (include)

Just for the records, not a showstopper for me.

toeb commented 9 years ago

Ok - actually behaves "correctly".
The problem is that cmakepp needs a temp folder were it can put generated files. In the root cmakepp.cmake file there is a section which tries to find a suitable temp directory. I do not know of the linux equivalent to the windows TMP environment variable so I just use a subdirectory at the current location

# get temp dir which is needed by a couple of functions in cmakepp
set(cmakepp_tmp_dir "$ENV{TMP}")
if(NOT cmakepp_tmp_dir)
    set(cmakepp_tmp_dir "${CMAKE_CURRENT_LIST_DIR}/tmp")
endif()
file(TO_CMAKE_PATH "${cmakepp_tmp_dir}" cmakepp_tmp_dir)
15knots commented 9 years ago

TMPDIR=/tmp Edit: Sorry, this might be misleading. The env-var name to get is TMPDIR.

But no per-user temp dir as on windos.

But isn´t there a cmake variable/property for temp dir already?

Edit Asked on cmake@cmake.org, waiting for answer

15knots commented 9 years ago

Answered on cmake@cmake.org:

Why not go with somewhere in the build directory? It is already full of temporary build artifacts.

toeb commented 9 years ago

That will not work because cmakepp is often executed in script mode. In script mode the CMAKE_BINARY_DIR is the pwd. that means whenever you start cmakepp it will create a temp folder at that location.

Another reason to not put it in the binary dir is because cmakepp caches results heavily andif the temp dir changes the results would have to be regenerated which takes quite a while.

Therefore the solution has to be a global directory which is the same for every cmakepp instance. (except if configured otherwise)

is TMPDIR define on all unix platforms?

15knots commented 9 years ago

is TMPDIR define on all unix platforms?

According to http://en.wikipedia.org/wiki/TMPDIR I would say: yes. If not, you could use /tmp which is defined by the Filesystem Hierarchy Standard on Linux

toeb commented 9 years ago

I added a better strategy for deriving the tmp dir . first try to use TMP then try to use TMPDIR, then use the <cmakepp dir>/tmp I will close this issue as soon as I merge back into master (might take a while)

15knots commented 9 years ago

Please re-open. v 0.1.0-alpha gives

CMake Error at /usr/share/cmake/Modules/cmakepp.cmake:24868 (file): file Internal CMake error when trying to open file: /usr/share/cmake/Modules/tmp/fwrite_temp.cmake for writing. Call Stack (most recent call first): /usr/share/cmake/Modules/cmakepp.cmake:26377 (fwrite) /usr/share/cmake/Modules/cmakepp.cmake:11050 (fwrite_temp) /usr/share/cmake/Modules/cmakepp.cmake:29616 (eval) /usr/share/cmake/Modules/cmakepp.cmake:18929 (string_decode_semicolon) /usr/share/cmake/Modules/cmakepp.cmake:18742 (structured_list_parse) /usr/share/cmake/Modules/cmakepp.cmake:39343 (config_setup) CMakeLists.txt:35 (include)

toeb commented 9 years ago

The next release will have the fix. Do you want me to amend the v0.1.0 alpha version or rather wait for a new release?

15knots commented 9 years ago

Am Donnerstag, 19. M�rz 2015, 13:58:20 schrieb Tobias Becker:

The next release will have the fix. Do you want me to amend the v0.1.0 alpha version or rather wait for a new release?

I'll wait for the next release. Having rpms for cmakepp currently is a benefit, not a must.

I opted to re-enable building the the docs run all tests while packaging, instead of creating issues in cmakepp. Sadly, both fail, so currently there are no rpms for cmakepp. You may find a current packaging log at (for example) https://build.opensuse.org/package/live_build_log/home:15knots/cmakepp/SLE_12/x86_64 which could tell you about packaging/build problems.

To trigger a package build upon the next release, I see three options:

1) PM me on each release. 2) re-open one of the issues I'm watching. 3) Let github trigger the packaging on each commit http://openbuildservice.org/2013/11/22/Source-Update-Via_Token/

If you choose otion 2, please send me a personal email, so I can create & sent you the token. (I won't post it here for security reasons)

Overall packaging status can be viewed at https://build.opensuse.org/package/show/home:15knots/cmakepp

Cd wrttn wtht vwls s mch trsr.