Skip to content

Commit

Permalink
Move editbin logic to a separate cmake file
Browse files Browse the repository at this point in the history
  • Loading branch information
doxygen committed Feb 10, 2022
1 parent 5974c33 commit a627cf8
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 56 deletions.
16 changes: 2 additions & 14 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -91,18 +91,6 @@ if (WIN32)
set(CMAKE_REQUIRED_DEFINITIONS "-DLIBICONV_STATIC")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /bigobj") # needed for language.cpp on 64bit
add_definitions(-DLIBICONV_STATIC -D_CRT_SECURE_NO_WARNINGS)

find_program(EDITBIN editbin)
if(EDITBIN)
set(EDITBIN_FLAGS /nologo /OSVERSION:5.1)
if (enable_console)
set(EDITBIN_FLAGS ${EDITBIN_FLAGS} /SUBSYSTEM:CONSOLE,6.00)
set(EDITBIN_WIZARD_FLAGS ${EDITBIN_FLAGS})
else()
set(EDITBIN_WIZARD_FLAGS ${EDITBIN_FLAGS} /SUBSYSTEM:WINDOWS,6.00)
set(EDITBIN_FLAGS ${EDITBIN_FLAGS} /SUBSYSTEM:CONSOLE,6.00)
endif()
endif()
endif()
if (CMAKE_GENERATOR MATCHES "NMake Makefiles")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc")
Expand Down Expand Up @@ -132,8 +120,8 @@ endif ()
find_program(DOT NAMES dot)
find_package(PythonInterp REQUIRED)
find_package(FLEX REQUIRED)
if (FLEX_VERSION VERSION_LESS 2.6)
message(SEND_ERROR "Doxygen requires at least flex version 2.6 (installed: ${FLEX_VERSION})")
if (FLEX_VERSION VERSION_LESS 2.5.37)
message(SEND_ERROR "Doxygen requires at least flex version 2.5.37 (installed: ${FLEX_VERSION})")
endif()
find_package(BISON REQUIRED)
if (BISON_VERSION VERSION_LESS 2.7)
Expand Down
10 changes: 2 additions & 8 deletions addon/doxyapp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,8 @@ include_directories(
add_executable(doxyapp
doxyapp.cpp
)
if(EDITBIN)
add_custom_command(
TARGET doxyapp
POST_BUILD
COMMAND "${EDITBIN}" ${EDITBIN_FLAGS} "$<TARGET_FILE:doxyapp>"
VERBATIM)
endif()

include(ApplyEditbin)
apply_editbin(doxyapp console)
add_sanitizers(doxyapp)

if (use_libclang)
Expand Down
10 changes: 3 additions & 7 deletions addon/doxyparse/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,9 @@ include_directories(
add_executable(doxyparse
doxyparse.cpp
)
if(EDITBIN)
add_custom_command(
TARGET doxyparse
POST_BUILD
COMMAND "${EDITBIN}" ${EDITBIN_FLAGS} "$<TARGET_FILE:doxyparse>"
VERBATIM)
endif()

include(ApplyEditbin)
apply_editbin(doxyparse console)
add_sanitizers(doxyparse)

if (use_libclang)
Expand Down
21 changes: 7 additions & 14 deletions addon/doxysearch/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,7 @@ include_directories(
add_executable(doxyindexer
doxyindexer.cpp
)
if(EDITBIN)
add_custom_command(
TARGET doxyindexer
POST_BUILD
COMMAND "${EDITBIN}" ${EDITBIN_FLAGS} "$<TARGET_FILE:doxyindexer>"
VERBATIM)
endif()

target_link_libraries(doxyindexer
${XAPIAN_LIBRARIES}
${ZLIB_LIBRARIES}
Expand All @@ -33,18 +27,17 @@ target_link_libraries(doxyindexer
add_executable(doxysearch.cgi
doxysearch.cpp
)
if(EDITBIN)
add_custom_command(
TARGET doxysearch.cgi
POST_BUILD
COMMAND "${EDITBIN}" ${EDITBIN_FLAGS} "$<TARGET_FILE:doxysearch.cgi>"
VERBATIM)
endif()

target_link_libraries(doxysearch.cgi
doxygen_version
${XAPIAN_LIBRARIES}
${ZLIB_LIBRARIES}
${WIN_EXTRA_LIBS}
)

include(ApplyEditbin)
apply_editbin(doxyindexer console)
apply_editbin(doxysearch.cgi console)


install(TARGETS doxyindexer doxysearch.cgi DESTINATION bin)
11 changes: 5 additions & 6 deletions addon/doxywizard/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -124,12 +124,11 @@ doxywizard.rc

set_property(TARGET doxywizard PROPERTY WIN32_EXECUTABLE true)

if(EDITBIN)
add_custom_command(
TARGET doxywizard
POST_BUILD
COMMAND "${EDITBIN}" ${EDITBIN_WIZARD_FLAGS} "$<TARGET_FILE:doxywizard>"
VERBATIM)
include(ApplyEditbin)
if (enable_console)
apply_editbin(doxywizard console)
else()
apply_editbin(doxywizard windows)
endif()

if(Qt5Core_FOUND)
Expand Down
19 changes: 19 additions & 0 deletions cmake/ApplyEditbin.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# helper script for Windows to run editbin.exe on a generated executable
function(apply_editbin target_name target_type)
if (WIN32)
find_program(EDITBIN editbin)
if(EDITBIN)
set(EDITBIN_FLAGS /nologo /OSVERSION:5.1)
if (${target_type} STREQUAL "console")
set(EDITBIN_FLAGS ${EDITBIN_FLAGS} /SUBSYSTEM:CONSOLE,6.00)
elseif (${target_type} STREQUAL "windows")
set(EDITBIN_FLAGS ${EDITBIN_FLAGS} /SUBSYSTEM:WINDOWS,6.00)
endif()
add_custom_command(
TARGET ${target_name}
POST_BUILD
COMMAND "${EDITBIN}" ${EDITBIN_FLAGS} "$<TARGET_FILE:${target_name}>"
VERBATIM)
endif()
endif()
endfunction()
11 changes: 4 additions & 7 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -327,13 +327,10 @@ endif()
add_executable(doxygen
main.cpp
)
if(EDITBIN)
add_custom_command(
TARGET doxygen
POST_BUILD
COMMAND "${EDITBIN}" ${EDITBIN_FLAGS} "$<TARGET_FILE:doxygen>"
VERBATIM)
endif()

include(ApplyEditbin)
apply_editbin(doxygen console)

add_sanitizers(doxygen)

if (use_libclang)
Expand Down

0 comments on commit a627cf8

Please sign in to comment.