Update CMakeLists with dependencies

This commit is contained in:
2026-04-23 04:42:32 -05:00
parent 4fcf674989
commit efbff0b665
2 changed files with 63 additions and 8 deletions

View File

@@ -3,15 +3,75 @@ project(stethoscope
VERSION 1.0
LANGUAGES C)
set(CMAKE_C_STANDARD 99)
set(CMAKE_C_STANDARD_REQUIRED ON)
set(CMAKE_C_EXTENSIONS ON)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "RelWithDebInfo")
endif()
find_package(Threads REQUIRED)
find_package(PkgConfig QUIET)
add_executable(${PROJECT_NAME}
src/main.c
deps/vector/vector.c
)
if(PkgConfig_FOUND)
pkg_check_modules(INIH REQUIRED inih)
pkg_check_modules(MICROHTTPD REQUIRED libmicrohttpd)
pkg_check_modules(MXML REQUIRED mxml)
target_include_directories(${PROJECT_NAME} PRIVATE
${INIH_INCLUDE_DIRS}
${MICROHTTPD_INCLUDE_DIRS}
${MXML_INCLUDE_DIRS}
)
target_link_libraries(${PROJECT_NAME} PRIVATE
${INIH_LIBRARIES}
${MICROHTTPD_LIBRARIES}
${MXML_LIBRARIES}
)
else()
find_path(INIH_INCLUDE_DIR ini.h)
find_library(INIH_LIBRARY NAMES inih libinih)
if(NOT INIH_INCLUDE_DIR OR NOT INIH_LIBRARY)
message(FATAL_ERROR "inih not found")
endif()
find_path(MICROHTTPD_INCLUDE_DIR microhttpd.h)
find_library(MICROHTTPD_LIBRARY NAMES microhttpd libmicrohttpd)
if(NOT MICROHTTPD_INCLUDE_DIR OR NOT MICROHTTPD_LIBRARY)
message(FATAL_ERROR "libmicrohttpd not found")
endif()
find_path(MXML_INCLUDE_DIR mxml.h)
find_library(MXML_LIBRARY NAMES mxml libmxml mxml4)
if(NOT MXML_INCLUDE_DIR OR NOT MXML_LIBRARY)
message(FATAL_ERROR "mxml not found")
endif()
target_include_directories(${PROJECT_NAME} PRIVATE
${INIH_INCLUDE_DIR}
${MICROHTTPD_INCLUDE_DIR}
${MXML_INCLUDE_DIR}
)
target_link_libraries(${PROJECT_NAME} PRIVATE
${INIH_LIBRARY}
${MICROHTTPD_LIBRARY}
${MXML_LIBRARY}
)
endif()
target_link_libraries(${PROJECT_NAME} PRIVATE Threads::Threads)
include_directories(${CMAKE_BINARY_DIR} ${PROJECT_SOURCE_DIR})
add_subdirectory(src)
#file(COPY resources DESTINATION ${CMAKE_BINARY_DIR})
file(COPY www DESTINATION ${CMAKE_BINARY_DIR})
install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION bin)

View File

@@ -1,5 +0,0 @@
add_executable(${PROJECT_NAME}
main.c
../deps/vector/vector.c
)
target_link_libraries(${PROJECT_NAME} PUBLIC microhttpd pthread inih mxml)