MantisBT - CMake
View Issue Details
0015975CMakeCMakepublic2016-02-16 10:582016-06-10 14:21
stw_sesa 
geoffviola 
normalmajoralways
closedfixed 
x86Windows7
 
CMake 3.6CMake 3.6 
0015975: GHS Multi Generator: COPY_FILE in try_compile does not work
try_compile COPY_FILE: The GHS MULTI Compiler compiles+links the executable to "targetname.as", but the CMake Generator currently looks for "targetname" (without extension). As a folder with such a name exists in the build directory COPY_FILE copies the folder instead of the built executable and the try_compile execution does not fail.

Create a simple CMakeLists.txt like this:

try_compile(
    result
    "${CMAKE_BINARY_DIR}/CMakeFiles/CMakeTmp"
    "${CMAKE_SOURCE_DIR}/test.c"
    COPY_FILE "${CMAKE_BINARY_DIR}/test_executable"
)
message(STATUS "result of try_compile: " ${result})


Create a simple test program as "test.c":

int main(int argc, char *argv[])
{
    return 0;
}

Run CMake using GHS MULTI Generator (ARM Integrity).

Actual result:
try_compile succeeds and a empty folder "test_executable" is created in the build directory

Expected result:
try_compile succeeds and the built executable "test_executable" is located in the build directory
I've tried setting
set("CMAKE_EXECUTABLE_SUFFIX", ".as")
manually at various locations but it didn't work. Either it wasn't set at all or overwritten; I don't know.
No tags attached.
zip testproject.zip (824) 2016-03-08 07:47
https://public.kitware.com/Bug/file/5640/testproject.zip
Issue History
2016-02-16 10:58stw_sesaNew Issue
2016-03-08 07:46stw_sesaNote Added: 0040645
2016-03-08 07:47stw_sesaFile Added: testproject.zip
2016-03-21 10:36Brad KingNote Added: 0040737
2016-03-22 16:17Brad KingNote Added: 0040754
2016-03-22 16:17Brad KingAssigned To => geoffviola
2016-03-22 16:17Brad KingStatusnew => resolved
2016-03-22 16:17Brad KingResolutionopen => fixed
2016-03-22 16:17Brad KingFixed in Version => CMake 3.6
2016-03-22 16:17Brad KingTarget Version => CMake 3.6
2016-06-10 14:21Kitware RobotNote Added: 0041216
2016-06-10 14:21Kitware RobotStatusresolved => closed

Notes
(0040645)
stw_sesa   
2016-03-08 07:46   
adding
set(CMAKE_EXECUTABLE_SUFFIX ".as")

in
Modules\Compiler\GHS-C.cmake
Modules\Compiler\GHS-CXX.cmake

solves the problem for me.

Use the attached "testproject.zip" for testing.
I've tested using the Greenhills MULTI compiler version "201416".
(0040737)
Brad King   
2016-03-21 10:36   
There is a patch under discussion here:

 15975 Bug Fix GHS MULTI try compile
 http://thread.gmane.org/gmane.comp.programming.tools.cmake.devel/16068 [^]
(0040754)
Brad King   
2016-03-22 16:17   
Re 0015975:0040737: The patch from the mailing list has been applied:

 GHS: Fix try_compile
 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=bf3e76d2 [^]
(0041216)
Kitware Robot   
2016-06-10 14:21   
This issue tracker is no longer used. Further discussion of this issue may take place in the current CMake Issues page linked in the banner at the top of this page.