Created
May 23, 2024 11:27
-
-
Save lchagnoleau/74383d05879ef8fae4b921e7ee66e26d to your computer and use it in GitHub Desktop.
CMake multiple target by list
This file contains hidden or 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.21) | |
project(cmake_test LANGUAGES C) | |
set(target "t1" "t2" "t3") | |
foreach(t ${target}) | |
set(MESSAGE_TEXT "Hello, ${t}") | |
add_executable(${t} main.c) | |
target_compile_definitions(${t} PRIVATE MESSAGE_TEXT="${MESSAGE_TEXT}") | |
endforeach() |
This file contains hidden or 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
#include <stdio.h> | |
#ifndef MESSAGE_TEXT | |
#define MESSAGE_TEXT "Hello, World!" | |
#endif | |
int main() { | |
printf("%s\n", MESSAGE_TEXT); | |
return 0; | |
} |
Author
lchagnoleau
commented
May 23, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment