-
Notifications
You must be signed in to change notification settings - Fork 515
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Compile examples using CMake on Linux
- Loading branch information
Toni Rönkkö
committed
Sep 11, 2016
1 parent
6e2c0b8
commit bb9dae1
Showing
16 changed files
with
148 additions
and
1,177 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
*.vcproj | ||
CMakeCache.txt | ||
CMakeFiles | ||
CTestTestfile.cmake | ||
DartConfiguration.tcl | ||
cmake_install.cmake | ||
Testing | ||
Debug | ||
Release | ||
dirent.sln | ||
dirent.ncb | ||
dirent.suo | ||
*.dir | ||
locate.db | ||
Makefile | ||
t-compile | ||
t-dirent | ||
find | ||
ls | ||
locate | ||
updatedb | ||
*.user | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,33 @@ | ||
cmake_minimum_required (VERSION 2.8) | ||
cmake_minimum_required (VERSION 2.8.11) | ||
project (dirent) | ||
|
||
enable_language(C) | ||
enable_language (C) | ||
|
||
install(FILES include/dirent.h DESTINATION include) | ||
install (FILES include/dirent.h DESTINATION include) | ||
|
||
# Add include directory to path if current system omits dirent.h file. This | ||
# step is imporant for compiling the test programs under Linux. | ||
include (CheckIncludeFiles) | ||
check_include_files (dirent.h HAVE_DIRENT_H) | ||
if (NOT HAVE_DIRENT_H) | ||
include_directories (${CMAKE_SOURCE_DIR}/include) | ||
endif (NOT HAVE_DIRENT_H) | ||
|
||
include(CTest) | ||
add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure -C ${CMAKE_CFG_INTDIR}) | ||
function(add_test_executable TEST_NAME) | ||
# Build example programs | ||
add_executable (find examples/find.c) | ||
add_executable (ls examples/ls.c) | ||
add_executable (locate examples/locate.c) | ||
add_executable (updatedb examples/updatedb.c) | ||
|
||
# Build test programs | ||
include (CTest) | ||
add_custom_target (check COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure -C ${CMAKE_CFG_INTDIR}) | ||
function (add_test_executable TEST_NAME) | ||
add_executable (${TEST_NAME} EXCLUDE_FROM_ALL ${ARGN}) | ||
add_test(NAME ${TEST_NAME} WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} COMMAND $<TARGET_FILE:${TEST_NAME}>) | ||
add_dependencies(check ${TEST_NAME}) | ||
target_include_directories(${TEST_NAME} PUBLIC ${CMAKE_SOURCE_DIR}/include) | ||
endfunction(add_test_executable) | ||
add_test (NAME ${TEST_NAME} WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} COMMAND $<TARGET_FILE:${TEST_NAME}>) | ||
add_dependencies (check ${TEST_NAME}) | ||
endfunction (add_test_executable) | ||
|
||
add_test_executable (t-compile tests/t-compile.c) | ||
add_test_executable (t-dirent tests/t-dirent.c) | ||
|
||
add_test_executable(t-compile tests/t-compile.c) | ||
add_test_executable(t-dirent tests/t-dirent.c) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.