Skip to content

Commit 814e8f0

Browse files
committed
Regularize CMake project metadata and locations
Based on PRs OpenSimulationInterface/open-simulation-interface#872 and OpenSimulationInterface/open-simulation-interface#873 by @doganulus. Signed-off-by: Pierre R. Mai <pmai@pmsf.de>
1 parent 47d2faf commit 814e8f0

File tree

1 file changed

+25
-23
lines changed

1 file changed

+25
-23
lines changed

CMakeLists.txt

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,21 @@
11
cmake_minimum_required(VERSION 3.10)
22

3-
project(open_simulation_interface)
4-
53
# Toplevel check
64
set(OSI_IS_TOP_LEVEL OFF)
75
if(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
86
set(OSI_IS_TOP_LEVEL ON)
97
endif()
108

11-
# Set the C++ standard
12-
set(CMAKE_CXX_STANDARD 17 CACHE STRING "C++ standard to be used")
13-
set(CMAKE_CXX_STANDARD_REQUIRED ON)
14-
15-
if(MSVC)
16-
add_compile_options(/wd4141 /wd4244 /wd4251 /wd4267 /wd4305 /wd4355 /wd4800 /wd4996)
17-
endif()
18-
199
# Set a default build type if none was specified
2010
set(default_build_type "Release")
21-
if(EXISTS "${CMAKE_SOURCE_DIR}/.git")
22-
set(default_build_type "Debug")
11+
12+
if(OSI_IS_TOP_LEVEL AND NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
13+
message(STATUS "Setting build type to '${default_build_type}' as none was specified.")
14+
set(CMAKE_BUILD_TYPE "${default_build_type}" CACHE
15+
STRING "Choose the type of build." FORCE)
16+
# Set the possible values of build type for cmake-gui
17+
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS
18+
"Debug" "Release" "MinSizeRel" "RelWithDebInfo")
2319
endif()
2420

2521
# read the version number from the file "VERSION"
@@ -32,19 +28,25 @@ foreach(LINE ${VERSION_CONTENTS})
3228
endforeach()
3329
set(OPEN_SIMULATION_INTERFACE_VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH})
3430

35-
set(${PROJECT_NAME}_SOVERSION "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}")
36-
set(${PROJECT_NAME}_LIBVERSION "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}")
31+
project(
32+
open_simulation_interface
33+
DESCRIPTION "A generic interface for the environmental perception of automated driving functions in virtual scenarios."
34+
HOMEPAGE_URL "https://github.com/OpenSimulationInterface/open-simulation-interface"
35+
VERSION ${OPEN_SIMULATION_INTERFACE_VERSION}
36+
LANGUAGES CXX
37+
)
3738

38-
# configure build version
39-
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
40-
message(STATUS "Setting build type to '${default_build_type}' as none was specified.")
41-
set(CMAKE_BUILD_TYPE "${default_build_type}" CACHE
42-
STRING "Choose the type of build." FORCE)
43-
# Set the possible values of build type for cmake-gui
44-
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS
45-
"Debug" "Release" "MinSizeRel" "RelWithDebInfo")
39+
# Set the C++ standard
40+
set(CMAKE_CXX_STANDARD 17 CACHE STRING "C++ standard to be used")
41+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
42+
43+
if(MSVC)
44+
add_compile_options(/wd4141 /wd4244 /wd4251 /wd4267 /wd4305 /wd4355 /wd4800 /wd4996)
4645
endif()
4746

47+
set(${PROJECT_NAME}_SOVERSION "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}")
48+
set(${PROJECT_NAME}_LIBVERSION "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}")
49+
4850
# Offer the user the choice of overriding the installation directories
4951
set(OSI_INSTALL_LIB_DIR lib CACHE PATH "Installation directory for libraries")
5052
set(OSI_INSTALL_INCLUDE_DIR include CACHE PATH "Installation directory for header files")
@@ -56,7 +58,7 @@ else()
5658
endif()
5759
set(OSI_INSTALL_CMAKE_DIR ${DEF_INSTALL_CMAKE_DIR} CACHE PATH "Installation directory for CMake files")
5860

59-
set(OSI_INSTALL_LIB_DIR ${OSI_INSTALL_LIB_DIR}/osi${VERSION_MAJOR})
61+
set(OSI_INSTALL_LIB_DIR ${OSI_INSTALL_LIB_DIR})
6062
set(OSI_INSTALL_INCLUDE_DIR ${OSI_INSTALL_INCLUDE_DIR}/osi${VERSION_MAJOR})
6163

6264
configure_file(open-simulation-interface/osi_version.proto.in osi_version.proto)

0 commit comments

Comments
 (0)