Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplified Windows build fix + some modernization of CMakeBuild files #16

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
build/*
30 changes: 14 additions & 16 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,24 +1,22 @@
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
PROJECT(SGP4)

include(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
if(COMPILER_SUPPORTS_CXX11)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
else()
message(SEND_ERROR "The compiler ${CMAKE_CXX_COMPILER} doesnt support C++11.")
endif()
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wextra")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wshadow")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wnon-virtual-dtor")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-long-long")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wcast-align")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wsign-conversion")
if(CMAKE_COMPILER_IS_GNUCC)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again is this compatible with clang?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I forgot about this. I will try to motivate the change request in the following days. (Just to mention: I actually use my branch of your code in a ground segment tool for satellites that will launch during 2020.)

add_compile_options(-Wall)
add_compile_options(-Wextra)
add_compile_options(-Wshadow)
add_compile_options(-Wnon-virtual-dtor)
add_compile_options(-pedantic)
add_compile_options(-Wno-long-long)
add_compile_options(-Wcast-align)
add_compile_options(-Wsign-conversion)
endif()

include_directories(libsgp4)

Expand All @@ -27,4 +25,4 @@ add_subdirectory(sattrack)
add_subdirectory(runtest)
add_subdirectory(passpredict)

file(COPY SGP4-VER.TLE DESTINATION ${PROJECT_BINARY_DIR})
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/SGP4-VER.TLE DESTINATION ${PROJECT_BINARY_DIR})
44 changes: 25 additions & 19 deletions libsgp4/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,32 @@ set(SRCS
Util.cc
Vector.cc)

set(INCS
CoordGeodetic.h
CoordTopocentric.h
DateTime.h
DecayedException.h
Eci.h
Globals.h
Observer.h
OrbitalElements.h
SatelliteException.h
SGP4.h
SolarPosition.h
TimeSpan.h
TleException.h
Tle.h
Util.h
Vector.h
)
set(INCS
CoordGeodetic.h
CoordTopocentric.h
DateTime.h
DecayedException.h
Eci.h
Globals.h
Observer.h
OrbitalElements.h
SatelliteException.h
SGP4.h
SolarPosition.h
TimeSpan.h
TleException.h
Tle.h
Util.h
Vector.h)

add_library(sgp4 STATIC ${SRCS} ${INCS})
target_include_directories(sgp4 PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
add_library(sgp4s SHARED ${SRCS} ${INCS})
install( TARGETS sgp4s LIBRARY DESTINATION lib )
target_include_directories(sgp4s PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})

if(WIN32)
install( TARGETS sgp4s RUNTIME DESTINATION lib )
else()
install( TARGETS sgp4s LIBRARY DESTINATION lib )
endif()
install( FILES ${INCS} DESTINATION include/SGP4 )
1 change: 1 addition & 0 deletions libsgp4/DateTime.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#ifndef DATETIME_H_
#define DATETIME_H_

#include <algorithm>
#include <iomanip>
#include <iostream>
#include <sstream>
Expand Down
3 changes: 1 addition & 2 deletions passpredict/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,4 @@ set(SRCS
add_executable(passpredict
${SRCS})
target_link_libraries(passpredict
sgp4
rt)
sgp4)
3 changes: 1 addition & 2 deletions runtest/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,4 @@ set(SRCS
add_executable(runtest
${SRCS})
target_link_libraries(runtest
sgp4
rt)
sgp4)
3 changes: 1 addition & 2 deletions sattrack/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,4 @@ set(SRCS
add_executable(sattrack
${SRCS})
target_link_libraries(sattrack
sgp4
rt)
sgp4)