2022-07-09 14:10:45 -07:00
|
|
|
# _____ _ _ __ #
|
|
|
|
# / ____| | | |/ / #
|
|
|
|
# ___ _ __ ___ _ __ | | __ | | ' / #
|
|
|
|
# / _ \| '_ \ / _ \ '_ \| | |_ |_ | | < #
|
|
|
|
# | (_) | |_) | __/ | | | |__| | |__| | . \ #
|
|
|
|
# \___/| .__/ \___|_| |_|\_____|\____/|_|\_\ #
|
|
|
|
# | | #
|
|
|
|
# |_| #
|
|
|
|
# #
|
|
|
|
# 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. #
|
|
|
|
|
2022-11-28 13:47:46 -08:00
|
|
|
# User options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
|
2023-02-14 08:16:19 -08:00
|
|
|
option(BUILD_EXAMPLE "Build demo" ON )
|
|
|
|
option(BUILD_MONO "Build C# example" OFF)
|
2022-11-28 13:47:46 -08:00
|
|
|
|
|
|
|
# CMake setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
|
|
|
|
cmake_minimum_required(VERSION 3.0) # You can downgrade to 2.8, but I don't maintain it anymore
|
2022-07-09 14:55:41 -07:00
|
|
|
cmake_policy(SET CMP0048 NEW)
|
2022-11-28 13:47:46 -08:00
|
|
|
cmake_policy(SET CMP0063 NEW) # Visibility of preset and hidden lines on shared libs
|
2022-07-09 14:10:45 -07:00
|
|
|
|
2023-02-15 05:14:19 -08:00
|
|
|
set( CMAKE_C_VISIBILITY_PRESET hidden)
|
2023-02-14 08:16:19 -08:00
|
|
|
set( CMAKE_VISIBILITY_INLINES_HIDDEN FALSE)
|
2022-11-28 13:47:46 -08:00
|
|
|
set( CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
|
|
|
|
|
|
|
|
# Project setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
|
2022-07-09 14:55:41 -07:00
|
|
|
set(GK_VERSION_MAJOR 3)
|
|
|
|
set(GK_VERSION_MINOR 0)
|
2022-11-28 13:47:46 -08:00
|
|
|
set(GK_VERSION_PATCH 3)
|
2022-07-09 14:10:45 -07:00
|
|
|
|
|
|
|
project(lib_opengjk_ce
|
|
|
|
LANGUAGES C
|
2022-07-09 14:55:41 -07:00
|
|
|
DESCRIPTION "openGJK library community edition (CE)"
|
|
|
|
HOMEPAGE_URL "www.mattiamontanari.com/opengjk/"
|
|
|
|
VERSION ${GK_VERSION_MAJOR}.${GK_VERSION_MINOR}.${GK_VERSION_PATCH}
|
2022-07-09 14:10:45 -07:00
|
|
|
)
|
|
|
|
|
2022-11-28 13:47:46 -08:00
|
|
|
# Compiler flags . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
|
2022-07-19 06:19:07 -07:00
|
|
|
message(STATUS "Compiler in use: ${CMAKE_C_COMPILER_ID}")
|
2022-11-28 13:47:46 -08:00
|
|
|
set( CMAKE_C_FLAGS_DEBUG "-O0 -g -Wall -Wunused")
|
2022-07-19 06:19:07 -07:00
|
|
|
set( CMAKE_C_FLAGS_RELEASE "-O3 -Werror")
|
|
|
|
|
|
|
|
if (CMAKE_C_COMPILER_ID STREQUAL "Clang")
|
2022-11-28 13:47:46 -08:00
|
|
|
set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
|
2022-07-19 06:19:07 -07:00
|
|
|
elseif (CMAKE_C_COMPILER_ID STREQUAL "GNU")
|
|
|
|
set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pedantic -Wunused-macros -Wno-unused-command-line-argument")
|
|
|
|
elseif (CMAKE_C_COMPILER_ID STREQUAL "Intel")
|
|
|
|
elseif (CMAKE_C_COMPILER_ID STREQUAL "MSVC")
|
|
|
|
endif()
|
2022-07-09 14:10:45 -07:00
|
|
|
|
2022-11-28 13:47:46 -08:00
|
|
|
# Target . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
|
2023-02-14 08:16:19 -08:00
|
|
|
|
|
|
|
if(BUILD_MONO)
|
2023-02-15 05:19:34 -08:00
|
|
|
set( CMAKE_C_VISIBILITY_PRESET default)
|
2023-02-14 08:16:19 -08:00
|
|
|
add_compile_definitions(CS_MONO_BUILD)
|
|
|
|
endif(BUILD_MONO)
|
|
|
|
|
2023-04-02 03:06:21 -07:00
|
|
|
if(SINGLE_PRECISION)
|
|
|
|
add_compile_definitions(USE_32BITS)
|
|
|
|
endif(SINGLE_PRECISION)
|
|
|
|
|
2023-02-14 08:16:19 -08:00
|
|
|
add_library( obj_openGJK
|
|
|
|
OBJECT
|
2022-11-28 13:47:46 -08:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/openGJK.c
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/include/openGJK/openGJK.h
|
2022-07-09 14:10:45 -07:00
|
|
|
)
|
|
|
|
|
2023-02-14 08:16:19 -08:00
|
|
|
target_include_directories( obj_openGJK
|
2022-11-28 13:47:46 -08:00
|
|
|
PUBLIC
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/include
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}
|
2022-07-09 14:10:45 -07:00
|
|
|
)
|
|
|
|
|
2023-02-14 08:16:19 -08:00
|
|
|
target_link_libraries(obj_openGJK PRIVATE m)
|
2022-11-28 13:47:46 -08:00
|
|
|
|
2023-02-14 08:16:19 -08:00
|
|
|
set_target_properties(obj_openGJK
|
2022-07-09 14:10:45 -07:00
|
|
|
PROPERTIES
|
2022-11-28 13:47:46 -08:00
|
|
|
C_STANDARD 11
|
2022-07-09 14:10:45 -07:00
|
|
|
PUBLIC_HEADER ${CMAKE_CURRENT_SOURCE_DIR}/include/openGJK/openGJK.h
|
2023-02-14 08:16:19 -08:00
|
|
|
POSITION_INDEPENDENT_CODE 1
|
2022-07-09 14:10:45 -07:00
|
|
|
)
|
|
|
|
|
2023-02-14 08:16:19 -08:00
|
|
|
add_library(opengjk_ce SHARED $<TARGET_OBJECTS:obj_openGJK>)
|
|
|
|
|
2022-11-28 13:47:46 -08:00
|
|
|
# Build demo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
|
2022-07-09 14:10:45 -07:00
|
|
|
if(BUILD_EXAMPLE)
|
|
|
|
add_subdirectory(examples/c)
|
|
|
|
endif(BUILD_EXAMPLE)
|
|
|
|
|
2022-11-28 13:47:46 -08:00
|
|
|
# Install . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
|
2022-07-09 14:10:45 -07:00
|
|
|
if (UNIX)
|
|
|
|
set(DESTDIR "/usr")
|
2023-02-14 08:16:19 -08:00
|
|
|
INSTALL(TARGETS opengjk_ce
|
2022-07-09 14:10:45 -07:00
|
|
|
LIBRARY DESTINATION "${DESTDIR}/lib"
|
|
|
|
PUBLIC_HEADER DESTINATION "${DESTDIR}/include"
|
2023-02-14 08:16:19 -08:00
|
|
|
PERMISSIONS WORLD_WRITE
|
2022-07-09 14:10:45 -07:00
|
|
|
)
|
|
|
|
endif (UNIX)
|
|
|
|
|
2022-11-28 13:47:46 -08:00
|
|
|
# Wrap up . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
|
2022-07-09 14:10:45 -07:00
|
|
|
message(STATUS "Version : " ${CMAKE_PROJECT_VERSION} )
|
2022-07-17 03:52:03 -07:00
|
|
|
message(STATUS "Build type : " ${CMAKE_BUILD_TYPE} )
|