@@ -16,7 +16,7 @@ project(
1616
1717include (cmake/StandardSettings.cmake)
1818include (cmake/Utils.cmake)
19- message (" \n Started CMake for ${PROJECT_NAME} v${PROJECT_VERSION} ...\n " )
19+ message (STATUS "Started CMake for ${PROJECT_NAME} v${PROJECT_VERSION} ...\n " )
2020
2121#
2222# Setup alternative names
@@ -53,7 +53,8 @@ include(cmake/Vcpkg.cmake)
5353include (cmake/SourcesAndHeaders.cmake)
5454
5555if (${PROJECT_NAME} _BUILD_EXECUTABLE)
56- add_executable (${PROJECT_NAME} ${sources} )
56+ add_executable (${PROJECT_NAME} ${exe_sources} )
57+ add_library (${PROJECT_NAME} _LIB ${headers} ${sources} )
5758elseif (${PROJECT_NAME} _BUILD_HEADERS_ONLY)
5859 add_library (${PROJECT_NAME} INTERFACE )
5960else ()
@@ -64,9 +65,15 @@ else()
6465 )
6566endif ()
6667
67- verbose_message("Found the following header files:\n ${headers} \n " )
68- verbose_message("Found the following source files:\n ${sources} \n " )
69- message ("Added all header and implementation files.\n " )
68+ verbose_message("Found the following header files:" )
69+ verbose_message(${headers} )
70+ verbose_message("Found the following source files:" )
71+ if (${PROJECT_NAME} _BUILD_EXECUTABLE)
72+ verbose_message(${exe_sources} )
73+ else ()
74+ verbose_message(${sources} )
75+ endif ()
76+ message (STATUS "Added all header and implementation files.\n " )
7077
7178#
7279# Set the project standard and warnings
@@ -109,9 +116,19 @@ else()
109116 PRIVATE
110117 ${CMAKE_CURRENT_SOURCE_DIR} /src
111118 )
119+ if (${PROJECT_NAME} _BUILD_EXECUTABLE)
120+ target_include_directories (
121+ ${PROJECT_NAME} _LIB
122+ PUBLIC
123+ $<INSTALL_INTERFACE:include >
124+ $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR} /include >
125+ PRIVATE
126+ ${CMAKE_CURRENT_SOURCE_DIR} /src
127+ )
128+ endif ()
112129endif ()
113130
114- message ("Finished setting up include directories." )
131+ message (STATUS "Finished setting up include directories." )
115132
116133#
117134# Model project dependencies
@@ -254,17 +271,17 @@ if(${PROJECT_NAME}_GENERATE_EXPORT_HEADER)
254271 include
255272 )
256273
257- message ("Generated the export header `${PROJECT_NAME_LOWERCASE} _export.h` and installed it." )
274+ message (STATUS "Generated the export header `${PROJECT_NAME_LOWERCASE} _export.h` and installed it." )
258275endif ()
259276
260- message ("Finished building requirements for installing the package.\n " )
277+ message (STATUS "Finished building requirements for installing the package.\n " )
261278
262279#
263280# Unit testing setup
264281#
265282
266283if (${PROJECT_NAME} _ENABLE_UNIT_TESTING)
267284 enable_testing ()
268- message ("Build unit tests for the project. Tests should always be found in the test folder\n " )
285+ message (STATUS "Build unit tests for the project. Tests should always be found in the test folder\n " )
269286 add_subdirectory (test )
270287endif ()
0 commit comments