Skip to content

Commit

Permalink
Merge pull request #21 from MattiaMontanari/ce
Browse files Browse the repository at this point in the history
Minimalistic community edition (CE) library
  • Loading branch information
MattiaMontanari authored Jul 9, 2022
2 parents 7471aa0 + d8c123c commit 1b84855
Show file tree
Hide file tree
Showing 29 changed files with 1,575 additions and 7,328 deletions.
174 changes: 82 additions & 92 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,92 +1,82 @@
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
# ##### # # # #
# #### ##### ###### # # # # # # # #
# # # # # # ## # # # # # #
# # # # # ##### # # # # #### # ### #
# # # ##### # # # # # # # # # # #
# # # # # # ## # # # # # # #
# #### # ###### # # ##### ##### # # #
# #
# This file is part of openGJK. #
# #
# OpenGJK is free software: you can redistribute it and/or modify #
# it under the terms of the GNU General Public License as published by #
# the Free Software Foundation, either version 3 of the License, or #
# any later version. #
# #
# OpenGJK is distributed in the hope that it will be useful, #
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See The #
# GNU General Public License for more details. #
# #
# You should have received a copy of the GNU General Public License #
# along with OpenGJK. If not, see <https://www.gnu.org/licenses/>. #
# #
# openGJK: open-source Gilbert-Johnson-Keerthi algorithm #
# Copyright (C) Mattia Montanari 2018 - 2020 #
# http://iel.eng.ox.ac.uk/?page_id=504 #
# #
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #

cmake_minimum_required(VERSION 3.13)

set(CMAKE_POLICY_DEFAULT_CMP0079 NEW)
set(LIBRARY_VERSION "2.0.3")

project(openGJKlib VERSION ${LIBRARY_VERSION} LANGUAGES C)

set(CMAKE_C_STANDARD 11)

list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
include(CMakeDefaults)
include(CompilerFlags)
include(PlatformDefaults)

message( "[${PROJECT_NAME}] CMake setting ..")
message(STATUS "Version : " ${CMAKE_PROJECT_VERSION} )
message(STATUS "Build type : " ${CMAKE_BUILD_TYPE} )

# Specify project specific and user custum options
include(CMakeProjectOptions)

set( SOURCE_FILES src/openGJK.c )
set( SOURCE_HEADS include/openGJK/openGJK.h)

IF(BUILD_STATIC_LIB)
add_library(${PROJECT_NAME} STATIC ${SOURCE_FILES} ${SOURCE_HEADS})
add_definitions(-DCMAKE_WINDOWS_EXPORT_ALL_SYMBOLS=TRUE -DBUILD_SHARED_LIBS=FALSE)
ELSE()
add_library(${PROJECT_NAME} SHARED ${SOURCE_FILES} ${SOURCE_HEADS})
add_definitions(-DCMAKE_WINDOWS_EXPORT_ALL_SYMBOLS=TRUE -DBUILD_SHARED_LIBS=TRUE)
ENDIF(BUILD_STATIC_LIB)

set_target_properties(${PROJECT_NAME} PROPERTIES PUBLIC_HEADER ${SOURCE_HEADS})

# Add compiler flags
include(CompilerFlags)

# Install setup
install(TARGETS ${PROJECT_NAME} PERMISSIONS WORLD_WRITE )

find_package(OpenMP REQUIRED)
if (OPENMP_FOUND)
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}")
endif()

# Link include file
target_include_directories( ${PROJECT_NAME} PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include")

target_link_libraries(${PROJECT_NAME} ${CMOCKA_LIBRARY} )

set(DESTDIR "/usr")
INSTALL(TARGETS ${PROJECT_NAME}
LIBRARY DESTINATION "${DESTDIR}/lib"
PUBLIC_HEADER DESTINATION "${DESTDIR}/include"
)

if (WITH_EXAMPLES)
add_subdirectory(examples/c)
endif (WITH_EXAMPLES)

message(STATUS "Completed CMake setting for ${PROJECT_NAME}" )
# _____ _ _ __ #
# / ____| | | |/ / #
# ___ _ __ ___ _ __ | | __ | | ' / #
# / _ \| '_ \ / _ \ '_ \| | |_ |_ | | < #
# | (_) | |_) | __/ | | | |__| | |__| | . \ #
# \___/| .__/ \___|_| |_|\_____|\____/|_|\_\ #
# | | #
# |_| #
# #
# Copyright 2022 Mattia Montanari, University of Oxford #
# #
# This program is free software: you can redistribute it and/or modify it under #
# the terms of the GNU General Public License as published by the Free Software #
# Foundation, either version 3 of the License. You should have received a copy #
# of the GNU General Public License along with this program. If not, visit #
# #
# https://www.gnu.org/licenses/ #
# #
# This program is distributed in the hope that it will be useful, but WITHOUT #
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS #
# FOR A PARTICULAR PURPOSE. See GNU General Public License for details. #

cmake_minimum_required(VERSION 2.8)
cmake_policy(SET CMP0048 NEW)
cmake_policy(SET CMP0079 NEW)

option(BUILD_EXAMPLE "Build demo" ON)

project(lib_opengjk_ce
LANGUAGES C
VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}
DESCRIPTION "openGJK library"
HOMEPAGE_URL "https://mattiamontanari.com/opengjk"
)

set( C_STANDARD 99)
set( CMAKE_CXX_VISIBILITY_PRESET hidden)
set( CMAKE_VISIBILITY_INLINES_HIDDEN 1)
set( CMAKE_POLICY_DEFAULT_CMP0079 NEW)
set( CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
set( CMAKE_INCLUDE_CURRENT_DIR TRUE)

set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -pedantic -Wunused-macros")
set( CMAKE_C_FLAGS_DEBUG "-O0 -g -Wall -Wno-unused-command-line-argument")
set( CMAKE_C_FLAGS_RELEASE "-O3 -Werror -Wno-unused-command-line-argument")

set( GK_PUBLIC_HEADER_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include)

add_library(${PROJECT_NAME}
STATIC
${CMAKE_CURRENT_SOURCE_DIR}/openGJK.c
${GK_PUBLIC_HEADER_DIR}/openGJK/openGJK.h
)

target_include_directories(
${PROJECT_NAME}
PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/include
${CMAKE_CURRENT_BINARY_DIR}
)

set_target_properties(${PROJECT_NAME}
PROPERTIES
PUBLIC_HEADER ${CMAKE_CURRENT_SOURCE_DIR}/include/openGJK/openGJK.h
)

if(BUILD_EXAMPLE)
add_subdirectory(examples/c)
endif(BUILD_EXAMPLE)

if (UNIX)
install(TARGETS ${PROJECT_NAME} PERMISSIONS WORLD_WRITE )
set(DESTDIR "/usr")
INSTALL(TARGETS ${PROJECT_NAME}
LIBRARY DESTINATION "${DESTDIR}/lib"
PUBLIC_HEADER DESTINATION "${DESTDIR}/include"
)
endif (UNIX)

# Wrap up feedback on setup
message(STATUS "Version : " ${CMAKE_PROJECT_VERSION} )
message(STATUS "Build type : " ${CMAKE_BUILD_TYPE} )
Loading

0 comments on commit 1b84855

Please sign in to comment.