The following issue has been SUBMITTED. ====================================================================== http://public.kitware.com/Bug/view.php?id=14935 ====================================================================== Reported By: th.thielemann Assigned To: ====================================================================== Project: CMake Issue ID: 14935 Category: CMake Reproducibility: always Severity: minor Priority: normal Status: new ====================================================================== Date Submitted: 2014-05-26 04:56 EDT Last Modified: 2014-05-26 04:56 EDT ====================================================================== Summary: file(APPEND "message...") writes nulls into file Description: I am using a shared folder between my Win7 and VmWare with Ubuntu 12.04. Fore some reasons I write out some properties into a file during cmake run. First line with file(WRITE "key=value"). All others with file(APPEND ...) Sucessful tested on Windows, Linux using the local file system. But if I share a folder between Windows and Linux, the result is "00 00 00 00 ... 00 The appended message".
Steps to Reproduce: Create the environment Win7 + VmWare + Ubuntu 12.04 LTS + shared folder. Here is my function function(write_env_script Mode EnvKey EnvValue) # Possible option flags list(FIND ARGN EXTEND IsExtend) # Resulting script name if(CMAKE_HOST_WIN32) file(TO_NATIVE_PATH ${EnvValue} EnvValue) endif() set(ScriptName ${PROJECT_BINARY_DIR}/setprojectenv${SSP_SCRIPT_TYPE}) # Reset mode to WRITE if file does not exist if(("${Mode}" STREQUAL "APPEND") AND (NOT EXISTS ${ScriptName})) set(Mode "WRITE") endif() # overwrite or extend the env variable's value set(EnvValueAlreadySet -1) if(NOT IsExtend EQUAL -1) if(NOT "$ENV{${EnvKey}}" STREQUAL "") if(CMAKE_HOST_UNIX) set(CurrentEnvValue "$ENV{${EnvKey}}:") elseif(CMAKE_HOST_WIN32) set(CurrentEnvValue "$ENV{${EnvKey}};") endif() endif() # Contains the env variable the value already? string(FIND "$ENV{${EnvKey}}" "${EnvValue}" EnvValueAlreadySet REVERSE) endif() if(EnvValueAlreadySet EQUAL -1) if(CMAKE_HOST_UNIX) #### Error! Replace the following line with workaround file(${Mode} ${ScriptName} "${PreviousScriptContent} export ${EnvKey}=${CurrentEnvValue}${EnvValue}\n" ) execute_process(COMMAND chmod u+x ${ScriptName} WORKING_DIRECTORY "${PROJECT_BINARY_DIR}") elseif(CMAKE_HOST_WIN32) file(${Mode} ${ScriptName} "set ${EnvKey}=${CurrentEnvValue}${EnvValue}\n\r" ) endif() endif() endfunction() The workaround for linux using VmWare share. if("${Mode}" STREQUAL "APPEND") file(READ ${ScriptName} PreviousScriptContent) endif() file(WRITE ${ScriptName} "${PreviousScriptContent} export ${EnvKey}=${CurrentEnvValue}${EnvValue}\n" ) Usage of the function: write_env_script(APPEND QT_PLUGIN_PATH "${QtLibs_PATH}/plugins") write_env_script(APPEND QML2_IMPORT_PATH "${QtLibs_PATH}/qml") write_env_script(APPEND PATH "${QtLibs_PATH}/bin" EXTEND) ====================================================================== Issue History Date Modified Username Field Change ====================================================================== 2014-05-26 04:56 th.thielemann New Issue ====================================================================== -- Powered by www.kitware.com Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Kitware offers various services to support the CMake community. For more information on each offering, please visit: CMake Support: http://cmake.org/cmake/help/support.html CMake Consulting: http://cmake.org/cmake/help/consulting.html CMake Training Courses: http://cmake.org/cmake/help/training.html Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Follow this link to subscribe/unsubscribe: http://public.kitware.com/cgi-bin/mailman/listinfo/cmake-developers