From e45d6559eec26b990e21c1af613996089c2d85ba Mon Sep 17 00:00:00 2001 From: pxntus Date: Wed, 26 Jun 2019 10:15:42 +0200 Subject: [PATCH 1/3] Windows build fixes. --- .gitignore | 1 + CMakeLists.txt | 18 ++++++++++-------- libsgp4/CMakeLists.txt | 8 +++++++- libsgp4/DateTime.h | 1 + passpredict/CMakeLists.txt | 3 +-- runtest/CMakeLists.txt | 3 +-- sattrack/CMakeLists.txt | 3 +-- 7 files changed, 22 insertions(+), 15 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..07ed706 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +build/* \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index 169ae92..2f42767 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,14 +11,16 @@ endif() 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_CXX_COMPILER_ID}" STREQUAL "GNU") + 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") +endif() include_directories(libsgp4) diff --git a/libsgp4/CMakeLists.txt b/libsgp4/CMakeLists.txt index b816645..8885978 100644 --- a/libsgp4/CMakeLists.txt +++ b/libsgp4/CMakeLists.txt @@ -37,5 +37,11 @@ set(SRCS add_library(sgp4 STATIC ${SRCS} ${INCS}) add_library(sgp4s SHARED ${SRCS} ${INCS}) -install( TARGETS sgp4s LIBRARY DESTINATION lib ) +if(WIN32) + install(TARGETS sgp4s + RUNTIME DESTINATION lib) +else() + install(TARGETS sgp4s + LIBRARY DESTINATION lib) +endif() install( FILES ${INCS} DESTINATION include/SGP4 ) diff --git a/libsgp4/DateTime.h b/libsgp4/DateTime.h index 0ddc35e..cb19ea6 100644 --- a/libsgp4/DateTime.h +++ b/libsgp4/DateTime.h @@ -18,6 +18,7 @@ #ifndef DATETIME_H_ #define DATETIME_H_ +#include #include #include #include diff --git a/passpredict/CMakeLists.txt b/passpredict/CMakeLists.txt index 5d6cf00..9975e9d 100644 --- a/passpredict/CMakeLists.txt +++ b/passpredict/CMakeLists.txt @@ -4,5 +4,4 @@ set(SRCS add_executable(passpredict ${SRCS}) target_link_libraries(passpredict - sgp4 - rt) + sgp4) diff --git a/runtest/CMakeLists.txt b/runtest/CMakeLists.txt index 7a1cf26..621d56c 100644 --- a/runtest/CMakeLists.txt +++ b/runtest/CMakeLists.txt @@ -4,5 +4,4 @@ set(SRCS add_executable(runtest ${SRCS}) target_link_libraries(runtest - sgp4 - rt) + sgp4) diff --git a/sattrack/CMakeLists.txt b/sattrack/CMakeLists.txt index 0664458..a8c5027 100644 --- a/sattrack/CMakeLists.txt +++ b/sattrack/CMakeLists.txt @@ -4,5 +4,4 @@ set(SRCS add_executable(sattrack ${SRCS}) target_link_libraries(sattrack - sgp4 - rt) + sgp4) From 822081817b39b022368ca97be460012d4cb61d8e Mon Sep 17 00:00:00 2001 From: pxntus Date: Wed, 26 Jun 2019 10:39:12 +0200 Subject: [PATCH 2/3] Modernized CMakeLists files a bit. - Setting C++11 and other compiler options without directly using compiler flags. - Using a target based approach (instead of directory based) for setting include directories. --- CMakeLists.txt | 30 +++++++++++++--------------- libsgp4/CMakeLists.txt | 44 +++++++++++++++++++++--------------------- 2 files changed, 35 insertions(+), 39 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2f42767..ffe2d77 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,25 +1,21 @@ 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) -if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") - 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) + 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) @@ -29,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}) diff --git a/libsgp4/CMakeLists.txt b/libsgp4/CMakeLists.txt index 8885978..87ef0fd 100644 --- a/libsgp4/CMakeLists.txt +++ b/libsgp4/CMakeLists.txt @@ -16,32 +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}) +target_include_directories(sgp4s PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) + if(WIN32) - install(TARGETS sgp4s - RUNTIME DESTINATION lib) + install( TARGETS sgp4s RUNTIME DESTINATION lib ) else() - install(TARGETS sgp4s - LIBRARY DESTINATION lib) + install( TARGETS sgp4s LIBRARY DESTINATION lib ) endif() install( FILES ${INCS} DESTINATION include/SGP4 ) From c74cca7c1ad3abe8de5ab055e5f6d08103ca3147 Mon Sep 17 00:00:00 2001 From: pxntus Date: Wed, 26 Jun 2019 11:21:21 +0200 Subject: [PATCH 3/3] Missed to remove directory based include directory line. --- CMakeLists.txt | 2 -- 1 file changed, 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ffe2d77..24f3b47 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,8 +18,6 @@ if(CMAKE_COMPILER_IS_GNUCC) add_compile_options(-Wsign-conversion) endif() -include_directories(libsgp4) - add_subdirectory(libsgp4) add_subdirectory(sattrack) add_subdirectory(runtest)