Browse Source

* add second sampler: dummy

master
Alex 'AdUser' Z 8 years ago
parent
commit
2f66696350
  1. 8
      CMakeLists.txt
  2. 20
      src/CMakeLists.txt
  3. 13
      src/samplers/dummy.c
  4. 2
      src/simdb-write.c

8
CMakeLists.txt

@ -9,6 +9,7 @@ include(GNUInstallDirs)
option(WITH_HARDENING "Enable hardening options" ON) option(WITH_HARDENING "Enable hardening options" ON)
option(WITH_TOOLS "Build library management tools" ON) option(WITH_TOOLS "Build library management tools" ON)
set(SAMPLER "magick" CACHE STRING "Library for sampling")
set(CMAKE_INSTALL_PREFIX "/usr/local") set(CMAKE_INSTALL_PREFIX "/usr/local")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -pedantic -std=c99") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -pedantic -std=c99")
@ -20,6 +21,12 @@ if (WITH_HARDENING)
add_definitions("-D_FORTIFY_SOURCE=2") add_definitions("-D_FORTIFY_SOURCE=2")
endif () endif ()
if (${SAMPLER} STREQUAL "dummy")
set(SAMPLER "dummy")
else ()
set(SAMPLER "magick")
endif ()
message(STATUS "Project : ${CNAME} v${VERSION}") message(STATUS "Project : ${CNAME} v${VERSION}")
message(STATUS "Compiler : ${CMAKE_C_COMPILER} (${CMAKE_C_COMPILER_ID} ${CMAKE_C_COMPILER_VERSION})") message(STATUS "Compiler : ${CMAKE_C_COMPILER} (${CMAKE_C_COMPILER_ID} ${CMAKE_C_COMPILER_VERSION})")
message(STATUS "- CFLAGS : ${CMAKE_C_FLAGS}") message(STATUS "- CFLAGS : ${CMAKE_C_FLAGS}")
@ -31,6 +38,7 @@ message(STATUS "Build type : ${CMAKE_BUILD_TYPE}")
message(STATUS "Options:") message(STATUS "Options:")
message(STATUS "- WITH_HARDENING : ${WITH_HARDENING}") message(STATUS "- WITH_HARDENING : ${WITH_HARDENING}")
message(STATUS "- WITH_TOOLS : ${WITH_TOOLS}") message(STATUS "- WITH_TOOLS : ${WITH_TOOLS}")
message(STATUS "- SAMPLER : ${SAMPLER}")
add_subdirectory("src") add_subdirectory("src")
add_subdirectory("tests") add_subdirectory("tests")

20
src/CMakeLists.txt

@ -1,8 +1,14 @@
set(LIB_SOURCES "database.c" "bitmap.c") set(LIB_SOURCES "database.c" "bitmap.c" "samplers/${SAMPLER}.c")
set(SAMPLER "magick") # TODO: GD2
add_library("simdb" SHARED ${LIB_SOURCES}) add_library("simdb" SHARED ${LIB_SOURCES})
set_property(TARGET "simdb" PROPERTY SONAME ${VERSION}) set_property(TARGET "simdb" PROPERTY SONAME ${VERSION})
if (${SAMPLER} STREQUAL "magick")
find_package(ImageMagick COMPONENTS MagickCore MagickWand)
target_link_libraries("simdb" ${ImageMagick_MagickCore_LIBRARY})
target_link_libraries("simdb" ${ImageMagick_MagickWand_LIBRARY})
endif ()
install(TARGETS "simdb" LIBRARY DESTINATION "lib") install(TARGETS "simdb" LIBRARY DESTINATION "lib")
if (WITH_TOOLS) if (WITH_TOOLS)
@ -13,11 +19,11 @@ if (WITH_TOOLS)
target_link_libraries("simdb-query" "simdb") target_link_libraries("simdb-query" "simdb")
install(TARGETS "simdb-query" RUNTIME DESTINATION "bin") install(TARGETS "simdb-query" RUNTIME DESTINATION "bin")
find_package(ImageMagick COMPONENTS MagickCore MagickWand) if (${SAMPLER} STREQUAL "dummy")
message(STATUS "Sampler set to 'dummy', not building 'simdb-write' tool")
add_executable("simdb-write" "simdb-write.c" "samplers/${SAMPLER}.c") else ()
add_executable("simdb-write" "simdb-write.c")
target_link_libraries("simdb-write" "simdb") target_link_libraries("simdb-write" "simdb")
target_link_libraries("simdb-write" ${ImageMagick_MagickCore_LIBRARY})
target_link_libraries("simdb-write" ${ImageMagick_MagickWand_LIBRARY})
install(TARGETS "simdb-write" RUNTIME DESTINATION "bin") install(TARGETS "simdb-write" RUNTIME DESTINATION "bin")
endif () endif ()
endif ()

13
src/samplers/dummy.c

@ -0,0 +1,13 @@
#include "../common.h"
#include "../simdb.h"
bool
simdb_record_create(simdb_rec_t * const rec, const char * const source) {
assert(rec != NULL);
assert(source != NULL);
(void)(rec);
(void)(source);
return false;
}

2
src/simdb-write.c

@ -81,7 +81,7 @@ int main(int argc, char **argv)
case add : case add :
if (rec.num == 0 || sample == NULL) if (rec.num == 0 || sample == NULL)
usage(EXIT_FAILURE); usage(EXIT_FAILURE);
if (simdb_record_create(&rec, sample) != 0) { if (!simdb_record_create(&rec, sample)) {
fprintf(stderr, "sampler failure\n"); fprintf(stderr, "sampler failure\n");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }

Loading…
Cancel
Save