Skip to content

Commit

Permalink
Generate at build time non .h include headers
Browse files Browse the repository at this point in the history
  • Loading branch information
sithlord48 committed Aug 29, 2022
1 parent 445be69 commit 8d75aad
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 9 deletions.
19 changes: 17 additions & 2 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,25 @@ endif()
# LIB_TARGET_PrivateLIBLINKS
macro(MAKE_LIBRARY LIB_TARGET HEADER_INSTALL_DIR)

add_library (${LIB_TARGET}
SHARED
add_library (${LIB_TARGET} SHARED
${${LIB_TARGET}_SRC}
${${LIB_TARGET}_HEADERS}
${${LIB_TARGET}_RESOURCES}
)
add_library (ff7tk::${LIB_TARGET} ALIAS ${LIB_TARGET})

#Generate the non .h ending header let the user include "HEADER" or "HEADER.h"
foreach ( HEADER ${${LIB_TARGET}_HEADERS})
if(${HEADER} MATCHES "_export.h$")
continue()
endif()
string(REPLACE ".h" "" newheader ${HEADER})
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/${newheader}
"#pragma once\n#include<${HEADER}>\n"
)
list(APPEND EXHEADERS ${CMAKE_CURRENT_BINARY_DIR}/${newheader})
endforeach()

if(APPLE)
set_target_properties(${LIB_TARGET} PROPERTIES BUILD_WITH_INSTALL_RPATH TRUE)
if(${BUILD_FRAMEWORKS})
Expand Down Expand Up @@ -86,6 +97,10 @@ macro(MAKE_LIBRARY LIB_TARGET HEADER_INSTALL_DIR)
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${HEADER_INSTALL_DIR}
COMPONENT ff7tk_headers
)
install (FILES ${EXHEADERS}
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${HEADER_INSTALL_DIR}
COMPONENT ff7tk_headers
)

if(UNIX)
if(NOT APPLE)
Expand Down
4 changes: 1 addition & 3 deletions src/data/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ set (ff7tk_HEADERS
FF7FieldItemList.h FF7Materia.h FF7Save_Types.h Type_FF7CHAR.h
FF7Achievements.h FF7Item.h FF7Save.h FF7Text.h Type_FF7CHOCOBO.h
FF7Char.h FF7Location.h FF7SaveInfo.h SaveIcon.h Type_materia.h
FF7ItemModel.h
${CMAKE_CURRENT_BINARY_DIR}/ff7tk_export.h
${CMAKE_CURRENT_BINARY_DIR}/ff7tkAbout.h
FF7ItemModel.h ff7tk_export.h ff7tkAbout.h
)

set ( ff7tk_RESOURCES
Expand Down
2 changes: 1 addition & 1 deletion src/formats/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ set(ff7tkFormats_HEADERS
TextureFile.h
TimFile.h
WindowBinFile.h
${CMAKE_CURRENT_BINARY_DIR}/ff7tkformats_export.h
ff7tkformats_export.h
)

set(ff7tkFormats_PublicLIBLINKS
Expand Down
2 changes: 1 addition & 1 deletion src/utils/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ set(ff7tkUtils_HEADERS
PsColor.h
PsfFile.h
QLockedFile.h
${CMAKE_CURRENT_BINARY_DIR}/ff7tkutils_export.h
ff7tkutils_export.h
)

set(ff7tkUtils_PublicLIBLINKS
Expand Down
2 changes: 1 addition & 1 deletion src/widgets/common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ set(ff7tkQtWidgets_HEADERS
DoubleCheckBox.h
HexLineEdit.h
QTaskBarButton.h
${CMAKE_CURRENT_BINARY_DIR}/ff7tkqtwidgets_export.h
ff7tkqtwidgets_export.h
)

set(ff7tkQtWidgets_PublicLIBLINKS
Expand Down
2 changes: 1 addition & 1 deletion src/widgets/data/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ set (ff7tkWidgets_HEADERS
MateriaEditor.h
OptionsWidget.h
SlotSelect.h
${CMAKE_CURRENT_BINARY_DIR}/ff7tkwidgets_export.h
ff7tkwidgets_export.h
)

set( ff7tkWidgets_PublicLIBLINKS
Expand Down

0 comments on commit 8d75aad

Please sign in to comment.