Commit 238b6f6d authored by Anonymous Maarten's avatar Anonymous Maarten

cmake: don't use CMAKE_SOURCE_DIR to enable building as subproject

parent 20f99db8
...@@ -9,11 +9,6 @@ add_executable(c++_example2 example2.cpp ) ...@@ -9,11 +9,6 @@ add_executable(c++_example2 example2.cpp )
add_executable(c++_example3 example3.cpp ) add_executable(c++_example3 example3.cpp )
add_executable(c++_example4 example4.cpp ) add_executable(c++_example4 example4.cpp )
target_include_directories(c++_example1 PRIVATE ${CMAKE_SOURCE_DIR}/lib)
target_include_directories(c++_example2 PRIVATE ${CMAKE_SOURCE_DIR}/lib)
target_include_directories(c++_example3 PRIVATE ${CMAKE_SOURCE_DIR}/lib)
target_include_directories(c++_example4 PRIVATE ${CMAKE_SOURCE_DIR}/lib)
target_link_libraries(c++_example1 ${libname}++ ) target_link_libraries(c++_example1 ${libname}++ )
target_link_libraries(c++_example2 ${libname}++ ) target_link_libraries(c++_example2 ${libname}++ )
target_link_libraries(c++_example3 ${libname}++ ) target_link_libraries(c++_example3 ${libname}++ )
......
...@@ -8,10 +8,6 @@ add_executable(c_example1 example1.c ) ...@@ -8,10 +8,6 @@ add_executable(c_example1 example1.c )
add_executable(c_example2 example2.c ) add_executable(c_example2 example2.c )
add_executable(c_example3 example3.c ) add_executable(c_example3 example3.c )
target_include_directories(c_example1 PRIVATE ${CMAKE_SOURCE_DIR}/lib)
target_include_directories(c_example2 PRIVATE ${CMAKE_SOURCE_DIR}/lib)
target_include_directories(c_example3 PRIVATE ${CMAKE_SOURCE_DIR}/lib)
target_link_libraries(c_example1 ${libname} ) target_link_libraries(c_example1 ${libname} )
target_link_libraries(c_example2 ${libname} ) target_link_libraries(c_example2 ${libname} )
target_link_libraries(c_example3 ${libname} ) target_link_libraries(c_example3 ${libname} )
...@@ -37,6 +37,14 @@ endif() ...@@ -37,6 +37,14 @@ endif()
add_library(${libname} ${libsrc} ${libinc}) add_library(${libname} ${libsrc} ${libinc})
add_library(${libname}++ ${libsrc_cpp} ${libinc_cpp}) add_library(${libname}++ ${libsrc_cpp} ${libinc_cpp})
target_include_directories(${libname} PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
target_include_directories(${libname}++ PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
set_target_properties(${libname} set_target_properties(${libname}
PROPERTIES LINKER_LANGUAGE C PROPERTIES LINKER_LANGUAGE C
PUBLIC_HEADER "${libinc}") PUBLIC_HEADER "${libinc}")
......
...@@ -4,8 +4,6 @@ else() ...@@ -4,8 +4,6 @@ else()
set(libname "config") set(libname "config")
endif() endif()
include_directories(${CMAKE_SOURCE_DIR}/lib)
add_executable(libconfig_tests add_executable(libconfig_tests
tests.c tests.c
) )
...@@ -18,5 +16,5 @@ target_link_libraries(libconfig_tests ...@@ -18,5 +16,5 @@ target_link_libraries(libconfig_tests
add_test( add_test(
NAME libconfig_tests NAME libconfig_tests
COMMAND libconfig_tests COMMAND libconfig_tests
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/tests
) )
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment