MantisBT - CMake
View Issue Details
0015018CMakeCMakepublic2014-07-12 16:412016-06-10 14:31
Andrew Aladjev 
Kitware Robot 
normalminoralways
closedmoved 
x86_64Gentoo2.2
CMake 3.0 
 
0015018: Try_run with project and target
"try_compile" has ability to work with complete project and it's target, "try_run" do not. Why?
No tags attached.
Issue History
2014-07-12 16:41Andrew AladjevNew Issue
2014-07-14 08:49Brad KingNote Added: 0036358
2014-11-12 06:00Andrew AladjevNote Added: 0037191
2016-06-10 14:29Kitware RobotNote Added: 0042585
2016-06-10 14:29Kitware RobotStatusnew => resolved
2016-06-10 14:29Kitware RobotResolutionopen => moved
2016-06-10 14:29Kitware RobotAssigned To => Kitware Robot
2016-06-10 14:31Kitware RobotStatusresolved => closed

Notes
(0036358)
Brad King   
2014-07-14 08:49   
It was simply never implemented. We almost never use try_run in practice anymore because it does not work for cross-compiling.

Besides, the whole-project signature of try_compile leaves the build tree around instead of using a temporary directory and then deleting it. That means the binary will be available to try running with execute_process.
(0037191)
Andrew Aladjev   
2014-11-12 06:00   
Ok. This works good

  cmake_minimum_required (VERSION "2.8")
  project ("check" "C")
  
  set (CMAKE_TRY_RUN false CACHE BOOL "try run targets after build")
  
  add_executable (
    "main"
    "${CMAKE_CURRENT_SOURCE_DIR}/main.c"
  )
  
  if (${CMAKE_TRY_RUN})
    add_custom_command(
      TARGET "main"
      POST_BUILD
      COMMAND "./main"
      WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
      COMMENT "Running main"
    )
  endif ()
(0042585)
Kitware Robot   
2016-06-10 14:29   
Resolving issue as `moved`.

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.