Merge pull request #37 from MattiaMontanari/moveHFFsInIFs

Fix cmake and compiler wwarnings
fixes-turtlebasket
Mattia Montanari 2022-11-28 22:48:40 +01:00 committed by GitHub
commit 9d9e8e4d26
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 30 additions and 28 deletions

View File

@ -20,13 +20,22 @@
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS #
# FOR A PARTICULAR PURPOSE. See GNU General Public License for details. # # FOR A PARTICULAR PURPOSE. See GNU General Public License for details. #
cmake_minimum_required(VERSION 2.8) # User options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
cmake_policy(SET CMP0048 NEW)
option(BUILD_EXAMPLE "Build demo" ON) option(BUILD_EXAMPLE "Build demo" ON)
# CMake setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
cmake_minimum_required(VERSION 3.0) # You can downgrade to 2.8, but I don't maintain it anymore
cmake_policy(SET CMP0048 NEW)
cmake_policy(SET CMP0063 NEW) # Visibility of preset and hidden lines on shared libs
set( CMAKE_C_VISIBILITY_PRESET hidden)
set( CMAKE_VISIBILITY_INLINES_HIDDEN TRUE)
set( CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
# Project setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
set(GK_VERSION_MAJOR 3) set(GK_VERSION_MAJOR 3)
set(GK_VERSION_MINOR 0) set(GK_VERSION_MINOR 0)
set(GK_VERSION_PATCH 0) set(GK_VERSION_PATCH 3)
project(lib_opengjk_ce project(lib_opengjk_ce
LANGUAGES C LANGUAGES C
@ -35,53 +44,46 @@ project(lib_opengjk_ce
VERSION ${GK_VERSION_MAJOR}.${GK_VERSION_MINOR}.${GK_VERSION_PATCH} VERSION ${GK_VERSION_MAJOR}.${GK_VERSION_MINOR}.${GK_VERSION_PATCH}
) )
set( C_STANDARD 99) # Compiler flags . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
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 compile flags
message(STATUS "Compiler in use: ${CMAKE_C_COMPILER_ID}") message(STATUS "Compiler in use: ${CMAKE_C_COMPILER_ID}")
set( CMAKE_C_FLAGS_DEBUG "-O0 -g -Wall") set( CMAKE_C_FLAGS_DEBUG "-O0 -g -Wall -Wunused")
set( CMAKE_C_FLAGS_RELEASE "-O3 -Werror") set( CMAKE_C_FLAGS_RELEASE "-O3 -Werror")
if (CMAKE_C_COMPILER_ID STREQUAL "Clang") if (CMAKE_C_COMPILER_ID STREQUAL "Clang")
# To use Clang, pass to cmake: -DCMAKE_C_COMPILER="clang" set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
elseif (CMAKE_C_COMPILER_ID STREQUAL "GNU") elseif (CMAKE_C_COMPILER_ID STREQUAL "GNU")
# To use Clang, pass to cmake: -DCMAKE_C_COMPILER="gcc"
set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pedantic -Wunused-macros -Wno-unused-command-line-argument") 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 "Intel")
elseif (CMAKE_C_COMPILER_ID STREQUAL "MSVC") elseif (CMAKE_C_COMPILER_ID STREQUAL "MSVC")
endif() endif()
set( GK_PUBLIC_HEADER_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include) # Target . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
add_library( ${PROJECT_NAME}
add_library(${PROJECT_NAME}
STATIC STATIC
${CMAKE_CURRENT_SOURCE_DIR}/openGJK.c ${CMAKE_CURRENT_SOURCE_DIR}/openGJK.c
${GK_PUBLIC_HEADER_DIR}/openGJK/openGJK.h ${CMAKE_CURRENT_SOURCE_DIR}/include/openGJK/openGJK.h
)
target_include_directories( ${PROJECT_NAME}
PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/include
${CMAKE_CURRENT_BINARY_DIR}
) )
target_link_libraries(${PROJECT_NAME} PRIVATE m) target_link_libraries(${PROJECT_NAME} PRIVATE m)
target_include_directories(
${PROJECT_NAME}
PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/include
${CMAKE_CURRENT_BINARY_DIR}
)
set_target_properties(${PROJECT_NAME} set_target_properties(${PROJECT_NAME}
PROPERTIES PROPERTIES
C_STANDARD 11
PUBLIC_HEADER ${CMAKE_CURRENT_SOURCE_DIR}/include/openGJK/openGJK.h PUBLIC_HEADER ${CMAKE_CURRENT_SOURCE_DIR}/include/openGJK/openGJK.h
) )
# Build demo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
if(BUILD_EXAMPLE) if(BUILD_EXAMPLE)
add_subdirectory(examples/c) add_subdirectory(examples/c)
endif(BUILD_EXAMPLE) endif(BUILD_EXAMPLE)
# Install . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
if (UNIX) if (UNIX)
install(TARGETS ${PROJECT_NAME} PERMISSIONS WORLD_WRITE ) install(TARGETS ${PROJECT_NAME} PERMISSIONS WORLD_WRITE )
set(DESTDIR "/usr") set(DESTDIR "/usr")
@ -91,6 +93,6 @@ if (UNIX)
) )
endif (UNIX) endif (UNIX)
# Wrap up feedback on setup # Wrap up . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
message(STATUS "Version : " ${CMAKE_PROJECT_VERSION} ) message(STATUS "Version : " ${CMAKE_PROJECT_VERSION} )
message(STATUS "Build type : " ${CMAKE_BUILD_TYPE} ) message(STATUS "Build type : " ${CMAKE_BUILD_TYPE} )