blob: f7a276fac2179416b08e66a5c776796d468d4c5e (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
find_program(CMAKE_C_COMPILER NAMES gcc cc)
if(NOT CMAKE_C_COMPILER)
message(FATAL_ERROR "C compiler not found!")
endif()
set(OUTPUT_FILE ${CMAKE_BINARY_DIR}/libhello_c.so)
add_custom_command(
OUTPUT ${OUTPUT_FILE}
COMMAND ${CMAKE_C_COMPILER} -shared -fPIC -o ${OUTPUT_FILE} ${CMAKE_CURRENT_SOURCE_DIR}/hello.c
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/hello.c
COMMENT "Compiling hello_c shared library..."
)
add_custom_target(hello_c ALL DEPENDS ${OUTPUT_FILE})
|