Skip to content

Instantly share code, notes, and snippets.

@pebbie
Last active March 4, 2019 14:46
Show Gist options
  • Save pebbie/bad2ed2f5d868de596b6b3f81ca35662 to your computer and use it in GitHub Desktop.
Save pebbie/bad2ed2f5d868de596b6b3f81ca35662 to your computer and use it in GitHub Desktop.
CMake build file for building serd on Windows & VS2017 (might be incomplete but works for me)
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.7)
PROJECT(serd)
SET(MAJOR 0)
SET(MINOR 30)
SET(PATCH 0)
SET(CMAKE_INCLUDE_CURRENT_DIR 1)
INCLUDE(CheckSymbolExists)
add_compile_definitions(_CRT_SECURE_NO_WARNINGS)
if (UNIX)
set(LIBS m)
endif (UNIX)
FILE(WRITE ${CMAKE_BINARY_DIR}/config.h.in
"#ifndef _SERD_CONFIG\n"
"#define _SERD_CONFIG\n"
"#cmakedefine HAVE_FILENO 1\n"
"#define SERD_VERSION \"${MAJOR}.${MINOR}.${PATCH}\"\n"
"#endif\n"
)
check_symbol_exists (fileno stdio.h HAVE_FILENO)
CONFIGURE_FILE(${CMAKE_BINARY_DIR}/config.h.in ${CMAKE_BINARY_DIR}/serd_config.h)
include_directories(src ${CMAKE_BINARY_DIR})
set(serd_LIB_SRCS
src/byte_source.c
src/env.c
src/n3.c
src/node.c
src/reader.c
src/reader.h
src/serd_internal.h
src/string.c
src/uri.c
src/writer.c
)
ADD_LIBRARY(serd ${serd_LIB_SRCS})
target_link_libraries(serd ${LIBS})
set_target_properties(serd PROPERTIES VERSION ${MAJOR}.${MINOR}.${PATCH} SOVERSION ${MAJOR}.${MINOR})
add_executable(serdi src/serdi.c)
target_link_libraries(serdi serd)
install(TARGETS serdi DESTINATION bin)
install(TARGETS serd DESTINATION lib)
install(FILES serd/serd.h DESTINATION include/serd)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment