getch_c/CMakeLists.txt

43 lines
1.2 KiB
CMake
Raw Normal View History

2021-02-22 15:17:06 -08:00
cmake_minimum_required(VERSION 3.16)
project(getch C)
set(CMAKE_C_STANDARD 11)
2021-02-24 20:46:16 -08:00
set(CMAKE_COLOR_MAKEFILE ON)
2021-02-22 15:17:06 -08:00
add_library(libgetch SHARED getch.c getch.h)
add_library(libgetch_static STATIC getch.c getch.h)
2021-02-22 15:33:01 -08:00
add_executable(example example.c )
2021-02-24 20:46:16 -08:00
add_executable(getchTest tests/test.c tests/getchTests.c)
add_test(NAME defaultTests
COMMAND "getchTest"
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
)
target_link_libraries(getchTest -L./build libgetch)
target_link_libraries(example -L./build libgetch)
2021-02-24 20:46:16 -08:00
if (ENABLE_TESTS EQUAL 1)
enable_testing()
endif ()
2021-02-22 15:17:06 -08:00
add_custom_target(escapeTest getchTest escapeReturnsTest
COMMAND getchTest specialKeyTest
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
USES_TERMINAL
)
set_target_properties(libgetch PROPERTIES PUBLIC_HEADER getch.h)
set_target_properties(libgetch PROPERTIES OUTPUT_NAME getch)
set_target_properties(libgetch_static PROPERTIES OUTPUT_NAME getch_static)
include(GNUInstallDirs)
install(TARGETS libgetch libgetch_static
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
PUBLIC_HEADER
DESTINATION ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR}
)