MantisBT - CMake | |||||
View Issue Details | |||||
ID | Project | Category | View Status | Date Submitted | Last Update |
0014935 | CMake | CMake | public | 2014-05-26 04:56 | 2016-06-10 14:31 |
Reporter | th.thielemann | ||||
Assigned To | Kitware Robot | ||||
Priority | normal | Severity | minor | Reproducibility | always |
Status | closed | Resolution | moved | ||
Platform | Vmware Player 6.0.2 on Win7 | OS | Ubuntu | OS Version | 12.04 LTS |
Product Version | |||||
Target Version | Fixed in Version | ||||
Summary | 0014935: 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) | ||||
Additional Information | |||||
Tags | CMake, linux, shared, Windows 7 | ||||
Relationships | |||||
Attached Files | |||||
Issue History | |||||
Date Modified | Username | Field | Change | ||
2014-05-26 04:56 | th.thielemann | New Issue | |||
2014-05-26 07:22 | David Cole | Note Added: 0035930 | |||
2014-05-26 08:50 | th.thielemann | Note Added: 0035931 | |||
2014-05-26 08:53 | th.thielemann | Tag Attached: CMake | |||
2014-05-26 08:53 | th.thielemann | Tag Attached: linux | |||
2014-05-26 08:53 | th.thielemann | Tag Attached: shared | |||
2014-05-26 08:53 | th.thielemann | Tag Attached: Windows 7 | |||
2016-06-10 14:29 | Kitware Robot | Note Added: 0042552 | |||
2016-06-10 14:29 | Kitware Robot | Status | new => resolved | ||
2016-06-10 14:29 | Kitware Robot | Resolution | open => moved | ||
2016-06-10 14:29 | Kitware Robot | Assigned To | => Kitware Robot | ||
2016-06-10 14:31 | Kitware Robot | Status | resolved => closed |
Notes | |||||
|
|||||
|
|
||||
|
|||||
|
|
||||
|
|||||
|
|