cmake_minimum_required(VERSION 3.30) project(leetcode C CXX) set(CMAKE_C_STANDARD 11) set(CMAKE_CXX_STANDARD 17) set(CMAKE_EXPORT_COMPILE_COMMANDS ON) include_directories(include) include(FetchContent) add_compile_options( -Wall -Wextra -O0 -g3 -fno-omit-frame-pointer ) if (UNIX) add_compile_options( -fsanitize=address -fsanitize=undefined ) add_link_options( -fsanitize=address -fsanitize=undefined ) endif () FetchContent_Declare( googletest URL https://github.com/google/googletest/releases/download/v1.15.2/googletest-1.15.2.tar.gz URL_HASH MD5=7e11f6cfcf6498324ac82d567dcb891e ) FetchContent_MakeAvailable(googletest) add_executable(13 src/13.c) add_executable(88 src/88.c) add_executable(100 src/100.c) add_executable(101 src/101.c) add_executable(104 src/104.c) add_executable(108 src/108.c) add_executable(110 src/110.c) add_executable(111 src/111.c) add_executable(112 src/119.c) add_executable(136 src/136.c) add_executable(141 src/141.c) add_executable(144 src/144.c) add_executable(145 src/145.c) add_executable(160 src/160.c) add_executable(168 src/168.c) add_executable(169 src/169.c) add_executable(171 src/171.c) add_executable(190 src/190.c) add_executable(191 src/191.c) add_executable(202 src/202.c) add_executable(219 src/219.c) add_executable(225 src/225.c) add_executable(228 src/228.c) add_executable(231 src/231.c) add_executable(258 src/258.c) add_executable(263 src/263.c) add_executable(268 src/268.c) add_executable(278 src/278.c) add_executable(338 src/338.c) add_executable(374 src/374.c) add_executable(2786 src/2786.c) add_executable(3110 src/3110.c) file(GLOB SRC_FILES "src/*.c") set(EXECUTABLE_SOURCES "${CMAKE_SOURCE_DIR}/src/13.c" "${CMAKE_SOURCE_DIR}/src/88.c" "${CMAKE_SOURCE_DIR}/src/100.c" "${CMAKE_SOURCE_DIR}/src/101.c" "${CMAKE_SOURCE_DIR}/src/104.c" "${CMAKE_SOURCE_DIR}/src/108.c" "${CMAKE_SOURCE_DIR}/src/110.c" "${CMAKE_SOURCE_DIR}/src/111.c" "${CMAKE_SOURCE_DIR}/src/112.c" "${CMAKE_SOURCE_DIR}/src/136.c" "${CMAKE_SOURCE_DIR}/src/141.c" "${CMAKE_SOURCE_DIR}/src/144.c" "${CMAKE_SOURCE_DIR}/src/145.c" "${CMAKE_SOURCE_DIR}/src/160.c" "${CMAKE_SOURCE_DIR}/src/168.c" "${CMAKE_SOURCE_DIR}/src/169.c" "${CMAKE_SOURCE_DIR}/src/171.c" "${CMAKE_SOURCE_DIR}/src/190.c" "${CMAKE_SOURCE_DIR}/src/191.c" "${CMAKE_SOURCE_DIR}/src/202.c" "${CMAKE_SOURCE_DIR}/src/219.c" "${CMAKE_SOURCE_DIR}/src/225.c" "${CMAKE_SOURCE_DIR}/src/228.c" "${CMAKE_SOURCE_DIR}/src/231.c" "${CMAKE_SOURCE_DIR}/src/258.c" "${CMAKE_SOURCE_DIR}/src/263.c" "${CMAKE_SOURCE_DIR}/src/268.c" "${CMAKE_SOURCE_DIR}/src/278.c" "${CMAKE_SOURCE_DIR}/src/338.c" "${CMAKE_SOURCE_DIR}/src/374.c" "${CMAKE_SOURCE_DIR}/src/2786.c" "${CMAKE_SOURCE_DIR}/src/3110.c" ) set(LIBRARY_SOURCES) foreach (SRC_FILE ${SRC_FILES}) if (NOT SRC_FILE IN_LIST EXECUTABLE_SOURCES) list(APPEND LIBRARY_SOURCES ${SRC_FILE}) endif () endforeach () add_library(leetcode STATIC ${LIBRARY_SOURCES}) add_subdirectory(tests)