Skip to content

Commit

Permalink
better cmake
Browse files Browse the repository at this point in the history
  • Loading branch information
xanthospap committed Sep 21, 2024
1 parent 859a72a commit 6b8c2aa
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 39 deletions.
46 changes: 36 additions & 10 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.1)
cmake_minimum_required(VERSION 3.8)

project(
datetime
Expand All @@ -7,9 +7,6 @@ project(
LANGUAGES CXX
)

# The library
add_subdirectory(src)

# The tests
include(CTest)
add_subdirectory(test//unit_tests)
Expand All @@ -19,12 +16,41 @@ if (sofa)
endif()
enable_testing()

add_compile_options(
-Wall -Wextra -Werror -pedantic -W -Wshadow -march=native
$<$<CONFIG:RELEASE>:-O2 -march=native>
$<$<CONFIG:DEBUG>:-g -pg -Wdisabled-optimization -DDEBUG>
)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED On)
set(CMAKE_CXX_EXTENSIONS Off)
add_compile_options(-Wall
-Wextra
-Werror
-pedantic
-W
-Wshadow
$<$<CONFIG:Release>:-O2>
$<$<CONFIG:Release>:-march=native>
$<$<CONFIG:Debug>:-g>
$<$<CONFIG:Debug>:-pg>
$<$<CONFIG:Debug>:-Wdisabled-optimization>
)
add_compile_definitions(
$<$<CONFIG:Debug>:DEBUG>
)

add_library(datetime)
target_include_directories(datetime
PUBLIC
${CMAKE_SOURCE_DIR}/include
)

add_subdirectory(src)

# Install headers at: $PREFIX/datetime/...
install(DIRECTORY ${CMAKE_SOURCE_DIR}/include/
DESTINATION include/datetime
)

# install library
install(TARGETS datetime
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin
)
39 changes: 10 additions & 29 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,32 +1,13 @@
add_library(datetime)

target_sources(datetime
PRIVATE
dat.cpp
datetime_io_core.cpp
modified_julian_day.cpp
month.cpp
strmonth.cpp
tpdateutc.cpp
twopartdates.cpp
utc2tai.cpp
ydoy_date.cpp
ymd_date.cpp
)

target_include_directories(datetime
PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/../include
)

# Install headers at: $PREFIX/datetime/...
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/../include/
DESTINATION include/datetime
)

# install library
install(TARGETS datetime
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin
${CMAKE_SOURCE_DIR}/src/dat.cpp
${CMAKE_SOURCE_DIR}/src/datetime_io_core.cpp
${CMAKE_SOURCE_DIR}/src/modified_julian_day.cpp
${CMAKE_SOURCE_DIR}/src/month.cpp
${CMAKE_SOURCE_DIR}/src/strmonth.cpp
${CMAKE_SOURCE_DIR}/src/tpdateutc.cpp
${CMAKE_SOURCE_DIR}/src/twopartdates.cpp
${CMAKE_SOURCE_DIR}/src/utc2tai.cpp
${CMAKE_SOURCE_DIR}/src/ydoy_date.cpp
${CMAKE_SOURCE_DIR}/src/ymd_date.cpp
)

0 comments on commit 6b8c2aa

Please sign in to comment.