Skip to content

Commit

Permalink
improve CMakeLists, build static library by default, improve MSVC han…
Browse files Browse the repository at this point in the history
…dling #86

* remove explicit static library target, build static library by default, use '-DBUILD_SHARED_LIBS=On' to get shared libs
* set compiler flags for MSVC correctly
  • Loading branch information
pageldev committed Nov 25, 2023
1 parent 822edeb commit 9a0437f
Showing 1 changed file with 8 additions and 15 deletions.
23 changes: 8 additions & 15 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@ project(libOpenDrive VERSION 0.3.0 DESCRIPTION ".xodr library")
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED True)

set(CMAKE_CXX_FLAGS "-Wall")
set(CMAKE_CXX_FLAGS_RELEASE "-O3")

if(MSVC)
SET(CMAKE_CXX_FLAGS "/EHsc")
SET(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS 1)
set(CMAKE_CXX_FLAGS "/EHsc /Wall")
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS 1)
set(CMAKE_CXX_FLAGS_RELEASE "/O2")
else()
set(CMAKE_CXX_FLAGS_DEBUG "-g")
set(CMAKE_CXX_FLAGS "-Wall")
set(CMAKE_CXX_FLAGS_DEBUG "-g")
set(CMAKE_CXX_FLAGS_RELEASE "-O3")
endif()

SET (SOURCES
set(SOURCES
src/Geometries/Arc.cpp
src/Geometries/CubicSpline.cpp
src/Geometries/Line.cpp
Expand All @@ -41,19 +41,12 @@ SET (SOURCES
thirdparty/pugixml/pugixml.cpp
)

add_library(OpenDrive SHARED ${SOURCES})
add_library(OpenDrive ${SOURCES})
target_include_directories(OpenDrive
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> $<INSTALL_INTERFACE:include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/thirdparty>)

add_library(OpenDriveStatic STATIC ${SOURCES})
target_include_directories(OpenDriveStatic
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> $<INSTALL_INTERFACE:include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/thirdparty>)
set_target_properties(OpenDriveStatic PROPERTIES POSITION_INDEPENDENT_CODE ON)

add_executable(test-xodr test.cpp)
target_link_libraries(test-xodr OpenDrive)

Expand Down

0 comments on commit 9a0437f

Please sign in to comment.