Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • CMake CMake
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 4,107
    • Issues 4,107
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 19
    • Merge requests 19
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Releases
  • Packages and registries
    • Packages and registries
    • Container Registry
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • External wiki
    • External wiki
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • CMakeCMake
  • CMakeCMake
  • Issues
  • #19771
Closed
Open
Issue created Sep 30, 2019 by Matthias Kretz@mattkretz

add_custom_target: document behavior when COMMAND is not a usable target

Test case

CMakeLists.txt:

project(add_custom_target_bug)
cmake_minimum_required(VERSION 3.10)
add_executable(target foo.cpp)
add_custom_target(run target DEPENDS target VERBATIM)

foo.cpp:

#include <iostream>

int main()
{
  std::cout << "Hello World.\n";
  return 0;
}

toolchain-arm-linux.cmake:

SET(CMAKE_SYSTEM_NAME Linux)
SET(CMAKE_SYSTEM_PROCESSOR arm)

This works

mkdir native
cd native
cmake ..
make VERBOSE=1 run

This fails

mkdir aarch64
cd aarch64
cmake -DCMAKE_TOOLCHAIN_FILE=toolchain-arm-linux.cmake ..
make VERBOSE=1 run

but this works (via binfmt calling qemu):

./target

Instead of calling ./target as the "native" version did, it calls target. Since the CWD isn't in the PATH, this can't work.

Discussion

It seems, cmake assumes cross compiled targets to not be executable on the host system. Due to binfmt support this assumption is incorrect. If necessary, the assumption should be trivially testable: Compile int main() {} and test whether it runs successfully.

Edited Oct 01, 2019 by Brad King
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking