# # hello/CMakeLists.txt -- # cmake_minimum_required(VERSION 3.12) project(HELLO) set(CMAKE_C_STANDARD 11) set(CMAKE_C_STANDARD_REQUIRED ON) set(CMAKE_C_EXTENSIONS OFF) set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF) if(CMAKE_C_COMPILER_ID MATCHES "Clang|GNU") add_compile_options(-Wall -Wextra -pedantic -Werror) endif() if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux") set(LINUX TRUE) endif() find_package(PkgConfig REQUIRED) add_executable(hello-naive hello-naive.c) if(${LINUX}) add_executable(hello-naive-static hello-naive.c) target_link_options(hello-naive-static PRIVATE -static) endif() add_executable(hello-stdio hello-stdio.c) add_executable(hello-args hello-args.c) add_executable(hello-getopt hello-getopt.c) add_executable(hello-sleep hello-sleep.c) add_executable(hello-signal hello-signal.c) add_executable(hello-write hello-write.c) if(${LINUX}) add_executable(hello-write-static hello-write.c) target_link_options(hello-write-static PRIVATE -static) endif() add_executable(hello-writev hello-writev.c) if(${LINUX}) add_executable(hello-syscall hello-syscall.c) endif() add_executable(hello-atexit hello-atexit.c) add_executable(hello-snowman hello-snowman.c) add_executable(hello-gettext hello-gettext.c) add_executable(hello-cpp hello-cpp.cc) # add_executable(hello-🌐 hello-🌐.c) add_executable(hello-dll hello-dll.c) target_link_libraries(hello-dll "-ldl") if(${LINUX}) enable_language(ASM) if(${CMAKE_SYSTEM_PROCESSOR} MATCHES "x86_64") add_executable(hello-x64-libc hello-x64-libc.s) target_link_options(hello-x64-libc PRIVATE -static) add_executable(hello-x64-syscall hello-x64-syscall.s) target_link_options(hello-x64-syscall PRIVATE -static -nostdlib) endif() if(${CMAKE_SYSTEM_PROCESSOR} MATCHES "rv64") add_executable(hello-rv64-libc hello-rv64-libc.s) target_link_options(hello-rv64-libc PRIVATE -static) add_executable(hello-rv64-syscall hello-rv64-syscall.s) target_link_options(hello-rv64-syscall PRIVATE -static -nostdlib) endif() endif() pkg_check_modules(GLIB2 glib-2.0) add_definitions(${GLIB2_CFLAGS}) add_executable(hello-glib hello-glib.c) target_link_libraries(hello-glib ${GLIB2_LDFLAGS}) add_executable(hello-glib-event hello-glib-event.c) target_link_libraries(hello-glib-event ${GLIB2_LDFLAGS}) add_executable(hello-glib-threads hello-glib-threads.c) target_link_libraries(hello-glib-threads ${GLIB2_LDFLAGS}) pkg_check_modules(NCURSES ncurses) add_definitions(${NCURSES_CFLAGS}) add_executable(hello-ncurses hello-ncurses.c) target_link_libraries(hello-ncurses ${NCURSES_LDFLAGS}) find_package(Intl REQUIRED) target_link_libraries(hello-gettext ${Intl_LIBRARIES}) target_include_directories(hello-gettext PUBLIC ${Intl_INCLUDE_DIRS})