Skip to content

Commit

Permalink
Use precompiled headders for gdalargumentparser.h
Browse files Browse the repository at this point in the history
  • Loading branch information
rouault committed Mar 12, 2024
1 parent 0d4e94e commit 840d961
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions apps/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,18 @@ target_include_directories(
appslib PRIVATE $<TARGET_PROPERTY:gdal_vrt,SOURCE_DIR> $<TARGET_PROPERTY:ogrsf_generic,SOURCE_DIR>
$<TARGET_PROPERTY:ogr_geojson,SOURCE_DIR> $<TARGET_PROPERTY:ogr_MEM,SOURCE_DIR>)

if (HAVE_WD188)
# This is a way to detect Intel Compiler
# and avoid "error: unable to read PCH file XXX/apps/CMakeFiles/binary_precompiled_headers.dir/cmake_pch.cxx.pch: 'No such file or directory'"
set(USE_GDALARGUMENTPARSER_H_PRECOMPILED_HEADER OFF)
else ()
set(USE_GDALARGUMENTPARSER_H_PRECOMPILED_HEADER ON)
endif ()

if (USE_GDALARGUMENTPARSER_H_PRECOMPILED_HEADER)
target_precompile_headers(appslib PRIVATE gdalargumentparser.h)
endif()

gdal_target_link_libraries(appslib PRIVATE PROJ::proj)

set_property(TARGET appslib PROPERTY POSITION_INDEPENDENT_CODE ${GDAL_OBJECT_LIBRARIES_POSITION_INDEPENDENT_CODE})
Expand All @@ -44,6 +56,13 @@ include(TargetPublicHeader)
target_public_header(TARGET ${GDAL_LIB_TARGET_NAME} HEADERS gdal_utils.h)

if (BUILD_APPS)
if (USE_GDALARGUMENTPARSER_H_PRECOMPILED_HEADER)
add_library(binary_precompiled_headers OBJECT gdalargumentparser.cpp)
gdal_standard_includes(binary_precompiled_headers)
target_compile_options(binary_precompiled_headers PRIVATE ${GDAL_CXX_WARNING_FLAGS} ${WFLAG_OLD_STYLE_CAST})
target_precompile_headers(binary_precompiled_headers PRIVATE gdalargumentparser.h)
endif()

# Default Apps
add_executable(gdalinfo gdal_utils_priv.h gdalinfo_bin.cpp)
add_executable(gdalbuildvrt gdal_utils_priv.h gdalbuildvrt_bin.cpp)
Expand Down Expand Up @@ -128,6 +147,9 @@ if (BUILD_APPS)
target_include_directories(
${UTILCMD} PRIVATE $<TARGET_PROPERTY:gdal_vrt,SOURCE_DIR> $<TARGET_PROPERTY:ogrsf_generic,SOURCE_DIR>
$<TARGET_PROPERTY:ogr_geojson,SOURCE_DIR> $<TARGET_PROPERTY:ogr_MEM,SOURCE_DIR>)
if (USE_GDALARGUMENTPARSER_H_PRECOMPILED_HEADER)
target_precompile_headers(${UTILCMD} REUSE_FROM binary_precompiled_headers)
endif ()
if (MSVC)
set_target_properties(${UTILCMD} PROPERTIES LINK_FLAGS "wsetargv.obj")
endif ()
Expand Down

0 comments on commit 840d961

Please sign in to comment.