cmake_minimum_required(VERSION 3.15) project(TextReader LANGUAGES CXX) # Set C++ standard and enable modern practices set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF) # Disable compiler-specific extensions # Configure where binaries will be placed set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) # For larger projects option(BUILD_TESTS "Build tests" OFF) if(BUILD_TESTS) enable_testing() add_subdirectory(tests) endif() # Install target (for packaging) # install(TARGETS text_reader DESTINATION bin) # install(DIRECTORY data/ DESTINATION share/text_reader/data) # Create the executable add_executable(text_reader src/main.cpp) # Copy data files to build directory file(COPY data/ DESTINATION ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/data) # Set compiler warnings target_compile_options(text_reader PRIVATE $<$:/W4 /WX> $<$,$>:-Wall -Wextra -pedantic -Werror> ) # Platform-specific configurations if(WIN32) target_compile_definitions(text_reader PRIVATE _CRT_SECURE_NO_WARNINGS) endif() # Include current directory for headers target_include_directories(text_reader PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})