add support in test project to choose C and/or C++ to compile

This commit is contained in:
Alfi Maulana 2023-01-08 12:35:22 +07:00
parent 582c9a40fa
commit 2511f03a88
No known key found for this signature in database
GPG Key ID: 2242A64C2A8DF5A4
2 changed files with 15 additions and 1 deletions

View File

@ -1,9 +1,17 @@
cmake_minimum_required(VERSION 3.0)
project(test)
option(BUILD_C "build hello world in C Language" OFF)
option(BUILD_CXX "build hello world in CXX Language" ON)
option(BUILD_TXT "build hello world txt file" OFF)
add_executable(hello_world hello_world.cpp)
if(BUILD_C)
add_executable(hello_world_c hello_world.c)
endif()
if(BUILD_CXX)
add_executable(hello_world hello_world.cpp)
endif()
if(BUILD_TXT)
add_custom_target(

6
test/hello_world.c Normal file
View File

@ -0,0 +1,6 @@
#include <stdio.h>
int main() {
printf("Hello world!\n");
return 0;
}