Skip to content

Commit

Permalink
fix: Changes executables to shared libraries
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaeldelboni committed Feb 14, 2021
1 parent 60aa5a8 commit 553bbc5
Show file tree
Hide file tree
Showing 24 changed files with 155 additions and 24 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,4 @@ add_custom_target(check ${CMAKE_COMMAND}

add_dependencies(coverage check)

# ----------------------- Test Configuration End ---------------------------- #
# ----------------------- Test Configuration End ---------------------------- #
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,22 @@ cmake .. -DCMAKE_BUILD_TYPE=Coverage; make; make coverage

</pre>

### Using with cmake FetchContent
```cmake
FetchContent_Declare(
sc_lib
GIT_REPOSITORY https://github.com/rafaeldelboni/sc.git
GIT_TAG master)
FetchContent_MakeAvailable(sc_lib)
add_executable(
myapp
myapp.c
)
target_link_libraries(
myapp
sc_str
)
```
7 changes: 6 additions & 1 deletion array/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@ set(CMAKE_C_STANDARD 99)
set(CMAKE_C_STANDARD_REQUIRED ON)
set(CMAKE_C_EXTENSIONS OFF)

add_executable(sc_array array_example.c sc_array.h sc_array.c)
add_library(
sc_array SHARED
sc_array.c
sc_array.h)

target_include_directories(sc_array PUBLIC ${CMAKE_CURRENT_LIST_DIR})

if (NOT CMAKE_C_COMPILER_ID MATCHES "MSVC")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -Wall -Wextra -pedantic -Werror")
Expand Down
7 changes: 6 additions & 1 deletion buffer/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@ set(CMAKE_C_STANDARD 99)
set(CMAKE_C_STANDARD_REQUIRED ON)
set(CMAKE_C_EXTENSIONS OFF)

add_executable(sc_buf buf_example.c sc_buf.h sc_buf.c)
add_library(
sc_buf SHARED
sc_buf.c
sc_buf.h)

target_include_directories(sc_buf PUBLIC ${CMAKE_CURRENT_LIST_DIR})

if (NOT CMAKE_C_COMPILER_ID MATCHES "MSVC")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -Wall -Wextra -pedantic -Werror")
Expand Down
7 changes: 6 additions & 1 deletion condition/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@ set(CMAKE_C_STANDARD 99)
set(CMAKE_C_STANDARD_REQUIRED ON)
set(CMAKE_C_EXTENSIONS OFF)

add_executable(sc_cond cond_example.c sc_cond.h sc_cond.c)
add_library(
sc_cond SHARED
sc_cond.c
sc_cond.h)

target_include_directories(sc_cond PUBLIC ${CMAKE_CURRENT_LIST_DIR})

if (NOT CMAKE_C_COMPILER_ID MATCHES "MSVC")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -pthread -Wall -Wextra -pedantic -Werror")
Expand Down
7 changes: 6 additions & 1 deletion crc32/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@ set(CMAKE_C_STANDARD 99)
set(CMAKE_C_STANDARD_REQUIRED ON)
set(CMAKE_C_EXTENSIONS OFF)

add_executable(sc_crc32 crc32_example.c sc_crc32.h sc_crc32.c)
add_library(
sc_crc32 SHARED
sc_crc32.c
sc_crc32.h)

target_include_directories(sc_crc32 PUBLIC ${CMAKE_CURRENT_LIST_DIR})

if (NOT CMAKE_C_COMPILER_ID MATCHES "MSVC")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -Wall -Wextra -pedantic -Werror")
Expand Down
7 changes: 6 additions & 1 deletion heap/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@ set(CMAKE_C_STANDARD 99)
set(CMAKE_C_STANDARD_REQUIRED ON)
set(CMAKE_C_EXTENSIONS OFF)

add_executable(sc_heap heap_example.c sc_heap.h sc_heap.c)
add_library(
sc_heap SHARED
sc_heap.c
sc_heap.h)

target_include_directories(sc_heap PUBLIC ${CMAKE_CURRENT_LIST_DIR})

if (NOT CMAKE_C_COMPILER_ID MATCHES "MSVC")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -Wall -Wextra -pedantic -Werror")
Expand Down
7 changes: 6 additions & 1 deletion ini/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@ set(CMAKE_C_STANDARD 99)
set(CMAKE_C_STANDARD_REQUIRED ON)
set(CMAKE_C_EXTENSIONS OFF)

add_executable(sc_ini ini_example.c sc_ini.h sc_ini.c)
add_library(
sc_ini SHARED
sc_ini.c
sc_ini.h)

target_include_directories(sc_ini PUBLIC ${CMAKE_CURRENT_LIST_DIR})

if (NOT CMAKE_C_COMPILER_ID MATCHES "MSVC")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -Wall -Wextra -pedantic -Werror")
Expand Down
7 changes: 6 additions & 1 deletion linked-list/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@ set(CMAKE_C_STANDARD 99)
set(CMAKE_C_STANDARD_REQUIRED ON)
set(CMAKE_C_EXTENSIONS OFF)

add_executable(sc_list list_example.c sc_list.h sc_list.c)
add_library(
sc_list SHARED
sc_list.c
sc_list.h)

target_include_directories(sc_list PUBLIC ${CMAKE_CURRENT_LIST_DIR})

if (NOT CMAKE_C_COMPILER_ID MATCHES "MSVC")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -Wall -Wextra -pedantic -Werror")
Expand Down
7 changes: 6 additions & 1 deletion logger/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@ set(CMAKE_C_STANDARD 99)
set(CMAKE_C_STANDARD_REQUIRED ON)
set(CMAKE_C_EXTENSIONS OFF)

add_executable(sc_log log_example.c sc_log.h sc_log.c)
add_library(
sc_log SHARED
sc_log.c
sc_log.h)

target_include_directories(sc_log PUBLIC ${CMAKE_CURRENT_LIST_DIR})

if (NOT CMAKE_C_COMPILER_ID MATCHES "MSVC")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -Wall -Wextra -pedantic -Werror -pthread")
Expand Down
7 changes: 6 additions & 1 deletion map/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@ set(CMAKE_C_STANDARD 99)
set(CMAKE_C_STANDARD_REQUIRED ON)
set(CMAKE_C_EXTENSIONS OFF)

add_executable(sc_map map_example.c sc_map.h sc_map.c)
add_library(
sc_map SHARED
sc_map.c
sc_map.h)

target_include_directories(sc_map PUBLIC ${CMAKE_CURRENT_LIST_DIR})

if (NOT CMAKE_C_COMPILER_ID MATCHES "MSVC")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -Wall -Wextra -pedantic -Werror")
Expand Down
7 changes: 6 additions & 1 deletion memory-map/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@ set(CMAKE_C_STANDARD 99)
set(CMAKE_C_STANDARD_REQUIRED ON)
set(CMAKE_C_EXTENSIONS OFF)

add_executable(sc_mmap mmap_example.c sc_mmap.h sc_mmap.c)
add_library(
sc_mmap SHARED
sc_mmap.c
sc_mmap.h)

target_include_directories(sc_mmap PUBLIC ${CMAKE_CURRENT_LIST_DIR})

if (NOT CMAKE_C_COMPILER_ID MATCHES "MSVC")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -Wall -Wextra -pedantic -Werror -pthread")
Expand Down
7 changes: 6 additions & 1 deletion mutex/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@ set(CMAKE_C_STANDARD 99)
set(CMAKE_C_STANDARD_REQUIRED ON)
set(CMAKE_C_EXTENSIONS OFF)

add_executable(sc_mutex mutex_example.c sc_mutex.h sc_mutex.c)
add_library(
sc_mutex SHARED
sc_mutex.c
sc_mutex.h)

target_include_directories(sc_mutex PUBLIC ${CMAKE_CURRENT_LIST_DIR})

if (NOT CMAKE_C_COMPILER_ID MATCHES "MSVC")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -Wall -Wextra -pedantic -Werror -pthread")
Expand Down
8 changes: 7 additions & 1 deletion option/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,13 @@ set(CMAKE_C_STANDARD 99)
set(CMAKE_C_STANDARD_REQUIRED ON)
set(CMAKE_C_EXTENSIONS OFF)

add_executable(sc_option option_example.c sc_option.h sc_option.c)
add_library(
sc_option SHARED
sc_option.c
sc_option.h)

target_include_directories(sc_option PUBLIC ${CMAKE_CURRENT_LIST_DIR})


if (NOT CMAKE_C_COMPILER_ID MATCHES "MSVC")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -Wall -Wextra -pedantic -Werror -pthread")
Expand Down
10 changes: 8 additions & 2 deletions perf/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,13 @@ set(CMAKE_C_STANDARD_REQUIRED ON)
set(CMAKE_C_EXTENSIONS OFF)

if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
add_executable(sc_perf perf_example.c sc_perf.h sc_perf.c)

add_library(
sc_perf SHARED
sc_perf.c
sc_perf.h)

target_include_directories(sc_perf PUBLIC ${CMAKE_CURRENT_LIST_DIR})

set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -pedantic -Werror -Wextra -Wall")
endif ()

7 changes: 6 additions & 1 deletion queue/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@ set(CMAKE_C_STANDARD 99)
set(CMAKE_C_STANDARD_REQUIRED ON)
set(CMAKE_C_EXTENSIONS OFF)

add_executable(sc_queue queue_example.c sc_queue.h sc_queue.c)
add_library(
sc_queue SHARED
sc_queue.c
sc_queue.h)

target_include_directories(sc_queue PUBLIC ${CMAKE_CURRENT_LIST_DIR})

if (NOT CMAKE_C_COMPILER_ID MATCHES "MSVC")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -Wall -Wextra -pedantic -Werror")
Expand Down
7 changes: 6 additions & 1 deletion sc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@ set(CMAKE_C_STANDARD 99)
set(CMAKE_C_STANDARD_REQUIRED ON)
set(CMAKE_C_EXTENSIONS OFF)

add_executable(sc sc_example.c sc.h sc.c)
add_library(
sc SHARED
sc.c
sc.h)

target_include_directories(sc PUBLIC ${CMAKE_CURRENT_LIST_DIR})

if (NOT CMAKE_C_COMPILER_ID MATCHES "MSVC")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -Wall -Wextra -pedantic -Werror -pthread")
Expand Down
7 changes: 6 additions & 1 deletion signal/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@ set(CMAKE_C_STANDARD 99)
set(CMAKE_C_STANDARD_REQUIRED ON)
set(CMAKE_C_EXTENSIONS OFF)

add_executable(sc_signal signal_example.c sc_signal.h sc_signal.c)
add_library(
sc_signal SHARED
sc_signal.c
sc_signal.h)

target_include_directories(sc_signal PUBLIC ${CMAKE_CURRENT_LIST_DIR})

if (NOT CMAKE_C_COMPILER_ID MATCHES "MSVC")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -Wall -Wextra -pedantic -Werror")
Expand Down
7 changes: 6 additions & 1 deletion socket/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@ set(CMAKE_C_STANDARD 99)
set(CMAKE_C_STANDARD_REQUIRED ON)
set(CMAKE_C_EXTENSIONS OFF)

add_executable(sc_socket sock_example.c sc_sock.h sc_sock.c)
add_library(
sc_socket SHARED
sc_sock.c
sc_sock.h)

target_include_directories(sc_socket PUBLIC ${CMAKE_CURRENT_LIST_DIR})

if (NOT CMAKE_C_COMPILER_ID MATCHES "MSVC")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -Wall -Wextra -pedantic -pthread -Werror")
Expand Down
7 changes: 6 additions & 1 deletion string/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@ set(CMAKE_C_STANDARD 99)
set(CMAKE_C_STANDARD_REQUIRED ON)
set(CMAKE_C_EXTENSIONS OFF)

add_executable(sc_str str_example.c sc_str.h sc_str.c)
add_library(
sc_str SHARED
sc_str.c
sc_str.h)

target_include_directories(sc_str PUBLIC ${CMAKE_CURRENT_LIST_DIR})

if (NOT CMAKE_C_COMPILER_ID MATCHES "MSVC")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -Wall -Wextra -pedantic -Werror")
Expand Down
7 changes: 6 additions & 1 deletion thread/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@ set(CMAKE_C_STANDARD 99)
set(CMAKE_C_STANDARD_REQUIRED ON)
set(CMAKE_C_EXTENSIONS OFF)

add_executable(sc_thread thread_example.c sc_thread.h sc_thread.c)
add_library(
sc_thread SHARED
sc_thread.c
sc_thread.h)

target_include_directories(sc_thread PUBLIC ${CMAKE_CURRENT_LIST_DIR})

if (NOT CMAKE_C_COMPILER_ID MATCHES "MSVC")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -pthread -Wextra -Wall -pedantic -Werror")
Expand Down
7 changes: 6 additions & 1 deletion time/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@ set(CMAKE_C_STANDARD 99)
set(CMAKE_C_STANDARD_REQUIRED ON)
set(CMAKE_C_EXTENSIONS OFF)

add_executable(sc_time time_example.c sc_time.h sc_time.c)
add_library(
sc_time SHARED
sc_time.c
sc_time.h)

target_include_directories(sc_time PUBLIC ${CMAKE_CURRENT_LIST_DIR})

if (NOT CMAKE_C_COMPILER_ID MATCHES "MSVC")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -Wall -Wextra -pedantic -Werror")
Expand Down
7 changes: 6 additions & 1 deletion timer/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@ set(CMAKE_C_STANDARD 99)
set(CMAKE_C_STANDARD_REQUIRED ON)
set(CMAKE_C_EXTENSIONS OFF)

add_executable(sc_timer timer_example.c sc_timer.h sc_timer.c)
add_library(
sc_timer SHARED
sc_timer.c
sc_timer.h)

target_include_directories(sc_timer PUBLIC ${CMAKE_CURRENT_LIST_DIR})

if (NOT CMAKE_C_COMPILER_ID MATCHES "MSVC")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -g -pedantic -Werror")
Expand Down
7 changes: 6 additions & 1 deletion uri/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@ set(CMAKE_C_STANDARD 99)
set(CMAKE_C_STANDARD_REQUIRED ON)
set(CMAKE_C_EXTENSIONS OFF)

add_executable(sc_uri uri_example.c sc_uri.h sc_uri.c)
add_library(
sc_uri SHARED
sc_uri.c
sc_uri.h)

target_include_directories(sc_uri PUBLIC ${CMAKE_CURRENT_LIST_DIR})

if (NOT CMAKE_C_COMPILER_ID MATCHES "MSVC")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -pedantic -Werror -Wall -Wextra")
Expand Down

0 comments on commit 553bbc5

Please sign in to comment.