From 41cc37223bc28bc0607d4550504fc960eb36ca18 Mon Sep 17 00:00:00 2001 From: Stefan Huber Date: Mon, 4 Nov 2013 09:32:50 +0100 Subject: [PATCH] initial commit --- .gitignore | 2 ++ CMakeLists.txt | 30 ++++++++++++++++++++++++++++++ LICENSE | 19 +++++++++++++++++++ build.sh | 7 +++++++ include/CMakeLists.txt | 2 ++ include/stick.h | 6 ++++++ lib/CMakeLists.txt | 10 ++++++++++ lib/libstick.pc.cmake | 9 +++++++++ lib/stick.c | 8 ++++++++ src/CMakeLists.txt | 17 +++++++++++++++++ src/config.h.cmake | 4 ++++ src/main.c | 13 +++++++++++++ 12 files changed, 127 insertions(+) create mode 100644 .gitignore create mode 100644 CMakeLists.txt create mode 100644 LICENSE create mode 100755 build.sh create mode 100644 include/CMakeLists.txt create mode 100644 include/stick.h create mode 100644 lib/CMakeLists.txt create mode 100644 lib/libstick.pc.cmake create mode 100644 lib/stick.c create mode 100644 src/CMakeLists.txt create mode 100644 src/config.h.cmake create mode 100644 src/main.c diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..89efb0f --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +build +*.swp diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..c9d4fb2 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,30 @@ +cmake_minimum_required (VERSION 2.6) +project (stick) + + +if(NOT CMAKE_SYSTEM_NAME STREQUAL "Windows") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -ansi") + set(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed" ) +endif() + +set(CMAKE_C_FLAGS_RELEASE "-DNDEBUG") +if(CMAKE_BUILD_TYPE STREQUAL "Release") + # CMAKE_C_FLAGS_RELEASE is appended, but we need to prepend -O2 to take + # effect + set(CMAKE_C_FLAGS "-O2 ${CMAKE_C_FLAGS}") +endif() + +set(PACKAGE_STRING stick) +set(PACKAGE_BUGREPORT stefan.huber@ist.ac.at) +set(PACKAGE_VERSION 0.1) + +if(NOT CMAKE_SYSTEM_NAME STREQUAL "Windows") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -std=c99") + # I would like to use -pedantic, but VTK devs are not sufficiently + # pedantic + set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Werror") +endif() + +add_subdirectory(include) +add_subdirectory(lib) +add_subdirectory(src) diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..bf7b18f --- /dev/null +++ b/LICENSE @@ -0,0 +1,19 @@ +Copyright (c) 2013 Stefan Huber + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..dddbb76 --- /dev/null +++ b/build.sh @@ -0,0 +1,7 @@ +cd $(dirname $0) +echo $PWD +mkdir -p build +cd build + +#cmake -D CMAKE_INSTALL_PREFIX:PATH=foo/ -D CMAKE_BUILD_TYPE="Debug" .. +cmake -D CMAKE_BUILD_TYPE="Release" .. diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt new file mode 100644 index 0000000..5e88e3f --- /dev/null +++ b/include/CMakeLists.txt @@ -0,0 +1,2 @@ +set(INCLUDE_DIR include/${PACKAGE_STRING}-${PACKAGE_VERSION}) +install (DIRECTORY ./ DESTINATION ${INCLUDE_DIR} FILES_MATCHING PATTERN "*.h") diff --git a/include/stick.h b/include/stick.h new file mode 100644 index 0000000..451a77e --- /dev/null +++ b/include/stick.h @@ -0,0 +1,6 @@ +#ifndef lyxtor_h +#define lyxtor_h + +void test(); + +#endif diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt new file mode 100644 index 0000000..3636f2e --- /dev/null +++ b/lib/CMakeLists.txt @@ -0,0 +1,10 @@ +set(stick_SRC stick.c) + +include_directories(${stick_SOURCE_DIR}/include) + +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libstick.pc.cmake ${CMAKE_CURRENT_BINARY_DIR}/libstick.pc @ONLY) + +add_library(stick SHARED ${stick_SRC}) + +install(TARGETS stick DESTINATION lib) +install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libstick.pc DESTINATION lib/pkgconfig COMPONENT "pkgconfig") diff --git a/lib/libstick.pc.cmake b/lib/libstick.pc.cmake new file mode 100644 index 0000000..1a57794 --- /dev/null +++ b/lib/libstick.pc.cmake @@ -0,0 +1,9 @@ +prefix=@CMAKE_INSTALL_PREFIX@ +libdir=${prefix}/lib +includedir=${prefix}/include + +Name: @PACKAGE_STRING@ +Description: A peristent homology libarary +Version: @PACKAGE_VERSION@ +Libs: -L${libdir} -lm +Cflags: -I${includedir}/@PACKAGE_STRING@-@PACKAGE_VERSION@ diff --git a/lib/stick.c b/lib/stick.c new file mode 100644 index 0000000..d6adeff --- /dev/null +++ b/lib/stick.c @@ -0,0 +1,8 @@ +#include + +#include "stick.h" + + +void test() { + printf("Hello world.\n"); +} diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt new file mode 100644 index 0000000..66012c5 --- /dev/null +++ b/src/CMakeLists.txt @@ -0,0 +1,17 @@ +set(stick_cli_SRC main.c) + +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h) +include_directories(${CMAKE_CURRENT_BINARY_DIR}) + +include_directories(${stick_SOURCE_DIR}/include) + +find_package(VTK REQUIRED) +INCLUDE(${VTK_USE_FILE}) + +add_executable(stick-cli ${stick_cli_SRC}) +target_link_libraries(stick-cli + stick + ${stick_cli_LIBS} + ${VTK_LIBRARIES} ) + +install (TARGETS stick-cli DESTINATION bin) diff --git a/src/config.h.cmake b/src/config.h.cmake new file mode 100644 index 0000000..9a2ff10 --- /dev/null +++ b/src/config.h.cmake @@ -0,0 +1,4 @@ +#define PACKAGE_STRING "@PACKAGE_STRING@" +#define PACKAGE_VERSION "@PACKAGE_VERSION@" +#define PACKAGE_BUGREPORT "@PACKAGE_BUGREPORT@" + diff --git a/src/main.c b/src/main.c new file mode 100644 index 0000000..2c3c4fd --- /dev/null +++ b/src/main.c @@ -0,0 +1,13 @@ +#include +#include + +#include + +int main(int argc, char* argv[]) { + (void) argc; + (void) argv; + + test(); + return EXIT_SUCCESS; +} + -- 2.39.5