Created
January 12, 2023 13:29
-
-
Save scivision/af5b4da75830d56e56a9e28cbf7a5428 to your computer and use it in GitHub Desktop.
find_program vis CMAKE_EXECUTABLE_SUFFIX
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cmake_minimum_required(VERSION 3.19) | |
get_property(cmake_role GLOBAL PROPERTY CMAKE_ROLE) | |
if(CMAKE_ROLE STREQUAL "PROJECT") | |
project(dummy LANGUAGES NONE) | |
endif() | |
# --- create test script | |
set(name "hello") | |
set(stem ${CMAKE_CURRENT_SOURCE_DIR}/${name}) | |
if(WIN32) | |
set(suffix .bat) | |
else() | |
set(suffix .sh) | |
endif() | |
set(fn ${stem}${suffix}) | |
if(NOT EXISTS ${fn}) | |
message(STATUS "write ${fn}") | |
file(WRITE ${fn} "echo \"hello\"") | |
file(CHMOD ${fn} FILE_PERMISSIONS OWNER_READ OWNER_EXECUTE) | |
endif() | |
# --- find test script | |
if(CMAKE_ROLE STREQUAL "PROJECT") | |
list(APPEND CMAKE_EXECUTABLE_SUFFIX ${suffix}) | |
message(STATUS "CMAKE_EXECUTABLE_SUFFIX: ${CMAKE_EXECUTABLE_SUFFIX}") | |
else() | |
string(APPEND name ${suffix}) | |
endif() | |
find_program(scr | |
NAMES ${name} | |
PATHS ${CMAKE_CURRENT_SOURCE_DIR} | |
NO_DEFAULT_PATH | |
REQUIRED | |
) | |
message(STATUS "script found: ${scr}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment