Skip to content

Commit

Permalink
CMake: add debug options to windows builds
Browse files Browse the repository at this point in the history
gcc and clang always build with '-g', enabling easier debugging, so
catch MSVC to the same.

This will create seperate program database (.pdb) files, which map
identifiers and statements in the project's source code to
corresponding identifiers and instructions in compiled apps.
These mapping files link the debugger to your source code, which
enables debugging.

Hopefully this will put a stop to those who want to build in windows
in debug mode (which is not possible, see #772)

This does not include the pdb files in the installers, so the only way
to get them is build locally.

Signed-off-by: Robin Getz <[email protected]>
  • Loading branch information
rgetz committed Apr 6, 2022
1 parent 29ca7fd commit 391f44a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
6 changes: 5 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,9 @@ if (NOT LOG_LEVEL)
endif()

if (MSVC)
add_compile_options(/W4 /wd4200 /wd4127 /wd4100)
add_compile_options(/Zi /W4 /wd4200 /wd4127 /wd4100)
# Zi produces a separate PDB file that contains all the symbolic debugging information
# W4 displays level 1, 2, 3, and 4 (informational) warnings that aren't off by default
# C4200: nonstandard extension used : zero-sized array in struct (usb.h)
# C4127: conditional expression is constant (IIO_ERROR and IIO_DEBUG macros)
# C4100: unreferenced parameter; same as -Wno-unused-parameter
Expand Down Expand Up @@ -474,6 +476,8 @@ target_link_libraries(iio LINK_PRIVATE ${LIBS_TO_LINK})

if (MSVC)
set_target_properties(iio PROPERTIES OUTPUT_NAME libiio)
target_link_options(iio PUBLIC /DEBUG)
# The linker puts debugging information into a program database (PDB) file
endif()

if(NOT SKIP_INSTALL_ALL)
Expand Down
10 changes: 10 additions & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,16 @@ add_executable(iio_readdev iio_readdev.c ${GETOPT_C_FILE} ${LIBIIO_RC})
add_executable(iio_reg iio_reg.c ${GETOPT_C_FILE} ${LIBIIO_RC})
add_executable(iio_writedev iio_writedev.c ${GETOPT_C_FILE} ${LIBIIO_RC})

if (MSVC)
target_link_options(iio_tests_helper PUBLIC /DEBUG)
target_link_options(iio_genxml PUBLIC /DEBUG)
target_link_options(iio_info PUBLIC /DEBUG)
target_link_options(iio_attr PUBLIC /DEBUG)
target_link_options(iio_readdev PUBLIC /DEBUG)
target_link_options(iio_reg PUBLIC /DEBUG)
target_link_options(iio_writedev PUBLIC /DEBUG)
endif()

target_link_libraries(iio_genxml iio iio_tests_helper)
target_link_libraries(iio_info iio iio_tests_helper)
target_link_libraries(iio_attr iio iio_tests_helper)
Expand Down

0 comments on commit 391f44a

Please sign in to comment.