Skip to content

Commit

Permalink
Improve CMakefile
Browse files Browse the repository at this point in the history
Incompatible change: Rename build option wxAutoExcel_BUILD_BUILD_SAMPLES to wxAutoExcel_BUILD_SAMPLES.

Create CMake config file both in the install and build folders.

Do not attempt to install .PDB file in the Release build.

Fix some extra whitespace and typos.
  • Loading branch information
PBfordev committed Apr 4, 2024
1 parent 42f4636 commit b5ba2ad
Showing 1 changed file with 11 additions and 16 deletions.
27 changes: 11 additions & 16 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ option(wxAutoExcel_BUILD_USE_PRECOMPILED "Use precompiled headers (requires CMak
set(wxAutoExcel_BUILD_VENDOR "custom" CACHE STRING "Vendor")
option(wxAutoExcel_BUILD_INSTALL "Create install target for the library" OFF)

option(wxAutoExcel_BUILD_BUILD_SAMPLES "Build samples" ${PROJECT_IS_TOP_LEVEL})
option(wxAutoExcel_BUILD_SAMPLES "Build samples" ${PROJECT_IS_TOP_LEVEL})

#################################
#
Expand Down Expand Up @@ -131,14 +131,14 @@ if(wxAutoExcel_BUILD_SHARED)
endif()

add_library(wxAutoExcel ${wxAutoExcel_BUILD_LIB_TYPE} ${SRCS})
target_include_directories(wxAutoExcel PUBLIC
target_include_directories(wxAutoExcel PUBLIC
$<BUILD_INTERFACE:${wxAutoExcel_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
)
target_link_libraries(wxAutoExcel PUBLIC ${wxWidgets_LIBRARIES})

# Make the library the startup project in MSVS. If the samples are built,
# it will be changed to minimal sample,
# it will be changed to minimal sample.
if(MSVC)
set_directory_properties(PROPERTIES VS_STARTUP_PROJECT wxAutoExcel)
endif()
Expand Down Expand Up @@ -230,14 +230,15 @@ if(wxAutoExcel_BUILD_USE_PRECOMPILED)
endif()

if(wxAutoExcel_BUILD_INSTALL)
install(CODE "message(STATUS \"Installing: Headers...\")")
install(DIRECTORY ${wxAutoExcel_SOURCE_DIR}/include/wx DESTINATION include)
install(TARGETS wxAutoExcel)
install(TARGETS wxAutoExcel EXPORT wxAutoExcelTargets)
install(EXPORT wxAutoExcelTargets FILE wxAutoExcelConfig.cmake DESTINATION lib/cmake/wxAutoExcel)
if(MSVC AND wxAutoExcel_BUILD_SHARED)
install(FILES $<TARGET_PDB_FILE:${PROJECT_NAME}> DESTINATION bin)
install(FILES $<$<CONFIG:Debug>:$<TARGET_PDB_FILE:${PROJECT_NAME}>> DESTINATION bin)
endif()
endif()

endif()
# create config also in the build dir, so find_package() can use that as well
export(TARGETS wxAutoExcel FILE wxAutoExcelConfig.cmake)

#################################
#
Expand Down Expand Up @@ -276,7 +277,7 @@ function(wxAutoExcel_add_sample name sourceFiles copyFiles)

endfunction()

if(wxAutoExcel_BUILD_BUILD_SAMPLES)
if(wxAutoExcel_BUILD_SAMPLES)

wxAutoExcel_add_sample(minimal "minimal.cpp" "")
if(MSVC)
Expand Down Expand Up @@ -313,18 +314,12 @@ else()
endif()
message(STATUS " Compiler id string: ${wxAutoExcel_COMPILER_ID_STR}")

if(wxAutoExcel_BUILD_INSTALL)
message(STATUS " Include folder: ${CMAKE_INSTALL_PREFIX}/include")
message(STATUS " Static/Import library folder: ${CMAKE_INSTALL_PREFIX}/lib")
message(STATUS " Runtime folder: ${CMAKE_INSTALL_PREFIX}/bin")
else()
message(STATUS " Include folder: ${wxAutoExcel_SOURCE_DIR}/include")
message(STATUS " Static/Import library folder: ${wxAutoExcel_ARCHIVE_DIR}")
message(STATUS " Runtime folder: ${wxAutoExcel_RUNTIME_DIR}")
endif()

message(STATUS " Use precompiled headers: ${wxAutoExcel_BUILD_USE_PRECOMPILED}")
message(STATUS " Build samples: ${wxAutoExcel_BUILD_BUILD_SAMPLES}")
message(STATUS " Build samples: ${wxAutoExcel_BUILD_SAMPLES}")
message(STATUS " ------")
message(STATUS " wxWidgets version: ${wxWidgets_VERSION_STRING}")
message(STATUS " wxWidgets link shared: ${wxAutoExcel_BUILD_LINK_WX_SHARED}")
Expand Down

0 comments on commit b5ba2ad

Please sign in to comment.