diff --git a/cmake/helper.cmake b/cmake/helper.cmake index 4711ee5..a21692c 100644 --- a/cmake/helper.cmake +++ b/cmake/helper.cmake @@ -41,6 +41,7 @@ function(install_library lib_name lib_install_dir bin_install_dir mod_dir instal RUNTIME DESTINATION ${bin_install_dir} LIBRARY DESTINATION ${lib_install_dir} ARCHIVE DESTINATION ${lib_install_dir} + INCLUDES DESTINATION ${install_dir}/include ) install( DIRECTORY ${mod_dir} @@ -56,13 +57,19 @@ function(install_documentation doc_dir install_dir) ) endfunction() +# Links the supplied library +function(link_library targ lib include_dir) + target_link_libraries(${targ} ${lib}) + target_include_directories(${targ} PUBLIC $) +endfunction() + # ------------------------------------------------------------------------------ # Helpful Macros macro(print_all_variables) - message(STATUS "---------- CURRENTLY DEFIND VARIABLES -----------") + message(STATUS "---------- CURRENTLY DEFINED VARIABLES -----------") get_cmake_property(varNames VARIABLES) foreach(varName ${varNames}) message(STATUS ${varName} = ${${varName}}) endforeach() message(STATUS "---------- END ----------") -endmacro() \ No newline at end of file +endmacro() diff --git a/test/ferror_test_c.c b/test/C/ferror_test_c.c similarity index 100% rename from test/ferror_test_c.c rename to test/C/ferror_test_c.c diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 13461cb..083e676 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,31 +1,23 @@ -macro(create_test testname codename) - add_executable(${testname} ${codename}) - target_link_libraries(${testname} ferror) - target_include_directories(${testname} PUBLIC ${PROJECT_BINARY_DIR}/include) - add_test( - NAME ${testname} - WORKING_DIRECTORY ${CMAKE_LIBRARY_OUTPUT_DIRECTORY} - COMMAND $ - ) -endmacro() - -macro(create_c_test testname codename) - add_executable(${testname} ${codename}) - target_link_libraries(${testname} ferror) - add_test( - NAME ${testname} - WORKING_DIRECTORY ${CMAKE_LIBRARY_OUTPUT_DIRECTORY} - COMMAND $ - ) -endmacro() +include("${PROJECT_SOURCE_DIR}/cmake/helper.cmake") -include_directories( - ${CMAKE_CURRENT_SOURCE_DIR} - $ +add_executable(ferror_test ferror_test.f90) +link_library(ferror_test ${PROJECT_NAME} ${PROJECT_INCLUDE_DIR}) +add_test( + NAME ferror_test + WORKING_DIRECTORY ${CMAKE_LIBRARY_OUTPUT_DIRECTORY} + COMMAND $ ) -create_test(ferror_test ferror_test.f90) - if (${BUILD_C_API}) - create_test(ferror_test_c ferror_test_c.c) -endif() \ No newline at end of file + include_directories( + ${CMAKE_CURRENT_SOURCE_DIR} + $ + ) + add_executable(ferror_test_c C/ferror_test_c.c) + link_library(ferror_test_c ${PROJECT_NAME} ${PROJECT_INCLUDE_DIR}) + add_test( + NAME ferror_test_c + WORKING_DIRECTORY ${CMAKE_LIBRARY_OUTPUT_DIRECTORY} + COMMAND $ + ) +endif()