Skip to content

Commit

Permalink
cmake WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
gwaldron committed May 6, 2024
1 parent 0a01368 commit c7b36ff
Show file tree
Hide file tree
Showing 9 changed files with 51 additions and 5,851 deletions.
11 changes: 1 addition & 10 deletions cmake/oe_win32.cmake
Original file line number Diff line number Diff line change
@@ -1,18 +1,9 @@
# Windows stuff

if(WIN32 AND NOT ANDROID)
if(MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /bigobj") #MSVC 2017/2019
add_definitions(-D_SCL_SECURE_NO_WARNINGS)
add_definitions(-D_CRT_SECURE_NO_DEPRECATE)
endif(MSVC)
endif(WIN32 AND NOT ANDROID)

# Custom plugin prefixes
if (CYGWIN)
SET(OSGEARTH_PLUGIN_PREFIX "cygwin_")
endif()

if(MINGW)
SET(OSGEARTH_PLUGIN_PREFIX "mingw_")
endif()
41 changes: 23 additions & 18 deletions cmake/osgearth-macros.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,8 @@ macro(add_osgearth_app)
set(multiValueArgs SOURCES HEADERS SHADERS TEMPLATES LIBRARIES INCLUDE_DIRECTORIES)
cmake_parse_arguments(MY "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})

set(OK_TO_BUILD TRUE)

if (MY_USE_IMGUI)
if(OSGEARTH_HAVE_IMGUI)
list(APPEND MY_INCLUDE_DIRECTORIES
Expand Down Expand Up @@ -216,32 +218,35 @@ macro(add_osgearth_app)
elseif (NOT EXISTS "${OSGEARTH_EMBEDDED_THIRD_PARTY_DIR}/imgui/imgui.cpp")
message(STATUS " ...because ImGui git submodule not found")
endif()
set(OK_TO_BUILD FALSE)
endif()
endif()

set(ALL_HEADERS ${MY_HEADERS})

include_directories(${MY_INCLUDE_DIRECTORIES})
if (OK_TO_BUILD)
set(ALL_HEADERS ${MY_HEADERS})

include_directories(${MY_INCLUDE_DIRECTORIES})

add_executable(${MY_TARGET} ${MY_SOURCES} ${ALL_HEADERS} ${MY_SHADERS} ${MY_TEMPLATES})
add_executable(${MY_TARGET} ${MY_SOURCES} ${ALL_HEADERS} ${MY_SHADERS} ${MY_TEMPLATES})

# We always need these so just link them here.
target_link_libraries(${MY_TARGET} PRIVATE osgEarth ${OPENSCENEGRAPH_LIBRARIES} ${MY_LIBRARIES})

# We always need these so just link them here.
target_link_libraries(${MY_TARGET} PRIVATE osgEarth ${OPENSCENEGRAPH_LIBRARIES} ${MY_LIBRARIES})

set_target_properties(${MY_TARGET} PROPERTIES PROJECT_LABEL "${MY_TARGET}")

# macos-specific
if(OSG_BUILD_PLATFORM_IPHONE)
set_target_properties(${TARGET_TARGETNAME} PROPERTIES XCODE_ATTRIBUTE_ENABLE_BITCODE ${IPHONE_ENABLE_BITCODE})
endif()
set_target_properties(${MY_TARGET} PROPERTIES PROJECT_LABEL "${MY_TARGET}")

# macos-specific
if(OSG_BUILD_PLATFORM_IPHONE)
set_target_properties(${TARGET_TARGETNAME} PROPERTIES XCODE_ATTRIBUTE_ENABLE_BITCODE ${IPHONE_ENABLE_BITCODE})
endif()

install(TARGETS ${MY_TARGET} RUNTIME DESTINATION bin)
install(TARGETS ${MY_TARGET} RUNTIME DESTINATION bin)

if(NOT MY_FOLDER)
set(MY_FOLDER "Ungrouped")
endif()
if(NOT MY_FOLDER)
set(MY_FOLDER "Ungrouped")
endif()

set_property(TARGET ${MY_TARGET} PROPERTY FOLDER "${MY_FOLDER}")
set_property(TARGET ${MY_TARGET} PROPERTY FOLDER "${MY_FOLDER}")
endif()

endmacro(add_osgearth_app)

Expand Down
65 changes: 27 additions & 38 deletions src/osgEarth/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ endif()
find_package(CURL REQUIRED)
find_package(GDAL REQUIRED)
find_package(SQLite3 REQUIRED)
find_package(tinyxml REQUIRED)

# optional
find_package(geos)
Expand Down Expand Up @@ -67,13 +68,6 @@ if(OSGEARTH_BUILD_ZIP_PLUGIN)
find_package(LibZip)
endif()

set(WITH_EXTERNAL_TINYXML FALSE CACHE BOOL "Use external TinyXML instead of inlining it")
if(WITH_EXTERNAL_TINYXML)
find_package(TinyXML)
endif()
add_definitions(-DTIXML_USE_STL)


# Logging SDK
if(spdlog_FOUND)
set(OSGEARTH_HAVE_SPDLOG ON)
Expand Down Expand Up @@ -108,6 +102,10 @@ if (OSGEARTH_ENABLE_WININET_FOR_HTTP)
endif()


# TinyXML should use STL containers:
add_definitions(-DTIXML_USE_STL)


# Files generated from templates ..................................

# Generate the Version header.
Expand Down Expand Up @@ -167,8 +165,6 @@ configure_shaders(
${SHADERS_CPP}
${TARGET_GLSL} )

SET(HEADER_PATH ${OSGEARTH_SOURCE_DIR}/include/${LIB_NAME})

SET(TARGET_H
AGG.h
AltitudeFilter
Expand Down Expand Up @@ -558,22 +554,22 @@ if(OSGEARTH_BUILD_LEGACY_CONTROLS_API)
MouseCoordsTool)
endif()

IF (NOT TINYXML_FOUND)
SET(TARGET_H
${TARGET_H}
tinystr.h
tinyxml.h
)
ENDIF (NOT TINYXML_FOUND)

IF (NOT TINYXML_FOUND)
SET(TINYXML_SRC
tinystr.cpp
tinyxml.cpp
tinyxmlerror.cpp
tinyxmlparser.cpp
)
ENDIF (NOT TINYXML_FOUND)
# IF (NOT TINYXML_FOUND)
# SET(TARGET_H
# ${TARGET_H}
# tinystr.h
# tinyxml.h
# )
# ENDIF (NOT TINYXML_FOUND)

# IF (NOT TINYXML_FOUND)
# SET(TINYXML_SRC
# tinystr.cpp
# tinyxml.cpp
# tinyxmlerror.cpp
# tinyxmlparser.cpp
# )
# ENDIF (NOT TINYXML_FOUND)

set(TARGET_SRC
AltitudeFilter.cpp
Expand Down Expand Up @@ -905,11 +901,6 @@ if(OSGEARTH_BUILD_LEGACY_CONTROLS_API)
MouseCoordsTool.cpp)
endif()

# MSVC 2017 and 2019 need /bigobj on debug build
if(MSVC AND MSVC_VERSION LESS 1930)
add_compile_options("$<$<CONFIG:Debug>:/bigobj>")
endif()

# Generate the protobuf headers and sources
IF(Protobuf_FOUND AND Protobuf_PROTOC_EXECUTABLE)
include_directories(${Protobuf_INCLUDE_DIR} ${CMAKE_CURRENT_BINARY_DIR})
Expand Down Expand Up @@ -937,11 +928,12 @@ endif()

message(STATUS "Building ${LIB_NAME} as a ${OSGEARTH_DYNAMIC_OR_STATIC} library")


add_osgearth_library(
TARGET ${LIB_NAME}
PUBLIC_HEADERS ${TARGET_H}
IMGUI_HEADERS ${TARGET_H_IMGUI}
SOURCES ${TARGET_SRC} ${TINYXML_SRC}
SOURCES ${TARGET_SRC}
SHADERS ${TARGET_GLSL}
TEMPLATES ${TARGET_IN} )

Expand All @@ -953,13 +945,9 @@ if (spdlog_FOUND)
endif()

# TinyXML support?
if (TINYXML_FOUND)
include_directories(${TINYXML_INCLUDE_DIR})
#LINK_WITH_VARIABLES(${LIB_NAME} TINYXML_LIBRARY)
#get_directory_property(output INCLUDE_DIRECTORIES)
target_link_libraries(${LIB_NAME} PRIVATE unofficial-tinyxml::unofficial-tinyxml)
message(STATUS ${output})
endif()
include_directories(${tinyxml_INCLUDE_DIR})
target_link_libraries(${LIB_NAME} PRIVATE unofficial-tinyxml::unofficial-tinyxml)
message(STATUS "Linking osgEarth with tinyxml")

# MBTiles support?
if(SQLITE3_FOUND)
Expand Down Expand Up @@ -1013,6 +1001,7 @@ endif()
# mesh optimizer optional library?
if(meshoptimizer_FOUND)
target_link_libraries(${LIB_NAME} PRIVATE meshoptimizer::meshoptimizer)
message(STATUS "Linking osgEarth with meshoptimizer")
endif()

# special purpose - do not remove
Expand Down
116 changes: 0 additions & 116 deletions src/osgEarth/tinystr.cpp

This file was deleted.

Loading

0 comments on commit c7b36ff

Please sign in to comment.