Skip to content

Commit b3fe56d

Browse files
committed
Fix compilation when used as submodule
There were problems due to the use of GenerateExportHeader when using this as git submodule. This has been fixed. Be sure to add EXT_INCLUDE in parent project to include_directories. Signed-off-by: Christian Rapp <0x2a@posteo.org>
1 parent 1002f07 commit b3fe56d

File tree

6 files changed

+24
-13
lines changed

6 files changed

+24
-13
lines changed

CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,7 @@ add_subdirectory(test)
1212
add_subdirectory(include/qAccordion)
1313
add_subdirectory(src)
1414

15+
# use ext_include in parent projects with include directrories. makes sure the generated headers are found
16+
if (QACCORDION_EXTERNAL)
17+
set (EXT_INCLUDE ${EXTERNAL_INCLUDE} PARENT_SCOPE)
18+
endif(QACCORDION_EXTERNAL)

include/qAccordion/clickableframe.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
#include <QLabel>
2525
#include <QGraphicsView>
2626

27-
#include "config.h"
28-
#include "qaccordion_export.h"
27+
#include <qaccordion_config.h>
28+
#include <qaccordion_export.h>
2929

3030
// TODO: No need to use a namespace for our constants as we are using them only
3131
// in this class

include/qAccordion/config.h.in

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
// You should have received a copy of the GNU General Public License
1515
// along with this program. If not, see <http://www.gnu.org/licenses/>.
1616

17-
#ifndef CONFIG_H_IN
18-
#define CONFIG_H_IN
17+
#ifndef QACCORDION_CONFIG_H_IN
18+
#define QACCORDION_CONFIG_H_IN
1919

2020
#define VERSION_MAJOR "@qAccordion_VERSION_MAJOR@"
2121
#define VERSION_MINOR "@qAccordion_VERSION_MINOR@"
@@ -27,4 +27,4 @@
2727
#define ATTR_UNUSED
2828
#endif
2929

30-
#endif // CONFIG_H_IN
30+
#endif // QACCORDION_CONFIG_H_IN

include/qAccordion/contentpane.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@
2828

2929
#include <memory>
3030

31-
#include "config.h"
32-
#include "qaccordion_export.h"
31+
#include <qaccordion_config.h>
32+
#include <qaccordion_export.h>
3333
#include "clickableframe.h"
3434
#include "qaccordion.h"
3535

include/qAccordion/qaccordion.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@
3232
#include <algorithm>
3333
#include <iterator>
3434

35-
#include "config.h"
36-
#include "qaccordion_export.h"
35+
#include <qaccordion_config.h>
36+
#include <qaccordion_export.h>
3737
#include "contentpane.h"
3838

3939
class ContentPane;

src/CMakeLists.txt

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ elseif(WIN32)
4141
endif (${MSVC_VERSION} LESS 1800)
4242
else ()
4343
message(FATAL_ERROR "Your C++ compiler does not support C++11.")
44-
endif (WIN32)
44+
endif ()
4545

4646
# include GenerateExportHeader module
4747
include(GenerateExportHeader)
@@ -57,20 +57,26 @@ message(STATUS "Found Qt version ${Qt5Widgets_VERSION_STRING}")
5757

5858
if (QACCORDION_EXTERNAL)
5959
set(base_path ${CMAKE_SOURCE_DIR}/external/qaccordion/)
60+
message(STATUS "Using qAccordion external config with base path: ${base_path}")
61+
# provide the current build path to parent scope. add this to include directories in parent projects
62+
set(EXTERNAL_INCLUDE
63+
"${CMAKE_CURRENT_BINARY_DIR}"
64+
PARENT_SCOPE
65+
)
6066
else ()
6167
set(base_path ${CMAKE_SOURCE_DIR})
6268
endif(QACCORDION_EXTERNAL)
6369

6470
include_directories(
65-
${PROJECT_BINARY_DIR} # include this directory so all moc headers and wrapped ui files are found
71+
${CMAKE_CURRENT_BINARY_DIR}
6672
${base_path}/include
6773
)
6874

6975
# configure a header file to pass some of the CMake settings
7076
# to the source code
7177
configure_file (
7278
${base_path}/include/qAccordion/config.h.in
73-
${CMAKE_CURRENT_BINARY_DIR}/config.h
79+
${CMAKE_CURRENT_BINARY_DIR}/qaccordion_config.h
7480
)
7581

7682
set (QACCORDION_SOURCE
@@ -102,5 +108,6 @@ install(TARGETS qAccordion DESTINATION lib)
102108
install(FILES ${base_path}/include/qAccordion/clickableframe.h DESTINATION include/qAccordion)
103109
install(FILES ${base_path}/include/qAccordion/contentpane.h DESTINATION include/qAccordion)
104110
install(FILES ${base_path}/include/qAccordion/qaccordion.h DESTINATION include/qAccordion)
105-
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/config.h DESTINATION include/qAccordion)
111+
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/qaccordion_config.h DESTINATION include/qAccordion)
106112
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/qaccordion_export.h DESTINATION include/qAccordion)
113+

0 commit comments

Comments
 (0)