Skip to content

Commit

Permalink
CMake adjustments (apple#69)
Browse files Browse the repository at this point in the history
* build: update cmake for TestHelpers rename

* build: make CMake build on macOS work

Unfortunately, XCTest importing is not working for some reason
currently.  However, this allows you to build on Darwin as follows:

```
cmake -G Ninja -D CMAKE_BUILD_TYPE=Release -D BUILD_TESTING=NO -S . -B out
ninja -C out
```

Windows and Linux builds remain functional.

* build: refactor Examples build with CMake

Although this goes contrary to best practices for CMake, this helps keep
the source tree a bit leaner for the Examples.
  • Loading branch information
compnerd authored Mar 9, 2020
1 parent be65f49 commit 215a8bf
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 23 deletions.
18 changes: 15 additions & 3 deletions Examples/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
add_subdirectory(math)
add_subdirectory(repeat)
add_subdirectory(roll)
add_executable(math
math/main.swift)
target_link_libraries(math PRIVATE
ArgumentParser)

add_executable(repeat
repeat/main.swift)
target_link_libraries(repeat PRIVATE
ArgumentParser)

add_executable(roll
roll/main.swift
roll/SplitMix64.swift)
target_link_libraries(roll PRIVATE
ArgumentParser)
4 changes: 0 additions & 4 deletions Examples/math/CMakeLists.txt

This file was deleted.

4 changes: 0 additions & 4 deletions Examples/repeat/CMakeLists.txt

This file was deleted.

5 changes: 0 additions & 5 deletions Examples/roll/CMakeLists.txt

This file was deleted.

2 changes: 1 addition & 1 deletion Sources/ArgumentParser/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@ set_target_properties(ArgumentParser PROPERTIES
target_compile_options(ArgumentParser PRIVATE
$<$<BOOL:${BUILD_TESTING}>:-enable-testing>)
target_link_libraries(ArgumentParser PRIVATE
Foundation)
$<$<NOT:$<PLATFORM_ID:Darwin>>:Foundation>)
2 changes: 1 addition & 1 deletion Sources/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
add_subdirectory(ArgumentParser)
if(BUILD_TESTING)
add_subdirectory(TestHelpers)
add_subdirectory(SAPTestHelpers)
endif()
6 changes: 3 additions & 3 deletions Sources/SAPTestHelpers/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
add_library(TestHelpers
add_library(SAPTestHelpers
StringHelpers.swift
TestHelpers.swift)
set_target_properties(TestHelpers PROPERTIES
set_target_properties(SAPTestHelpers PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_Swift_MODULE_DIRECTORY})
target_link_libraries(TestHelpers PUBLIC
target_link_libraries(SAPTestHelpers PUBLIC
ArgumentParser
XCTest)
2 changes: 1 addition & 1 deletion Tests/EndToEndTests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ add_library(EndToEndTests
SubcommandEndToEndTests.swift
ValidationEndToEndTests.swift)
target_link_libraries(EndToEndTests PUBLIC
TestHelpers)
SAPTestHelpers)
2 changes: 1 addition & 1 deletion Tests/UnitTests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ add_library(UnitTests
UsageGenerationTests.swift)
target_link_libraries(UnitTests PRIVATE
ArgumentParser
TestHelpers)
SAPTestHelpers)

0 comments on commit 215a8bf

Please sign in to comment.