CMake static library example added.
This commit is contained in:
parent
b6d6d84dcd
commit
7fa1a0a6d6
|
@ -0,0 +1,5 @@
|
|||
cmake_minimum_required (VERSION 2.6)
|
||||
project (HELLO)
|
||||
|
||||
add_subdirectory (libmean)
|
||||
add_subdirectory (test)
|
|
@ -0,0 +1 @@
|
|||
add_library (libmean mean.c)
|
|
@ -0,0 +1,5 @@
|
|||
//#include <stdio.h>
|
||||
|
||||
double mean(double a, double b) {
|
||||
return (a+b) / 2;
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
double mean(double, double);
|
|
@ -0,0 +1,7 @@
|
|||
include_directories (${HELLO_SOURCE_DIR}/libmean)
|
||||
|
||||
link_directories (${HELLO_BINARY_DIR}/libmean)
|
||||
|
||||
add_executable (helloDemo main)
|
||||
|
||||
target_link_libraries (helloDemo libmean)
|
|
@ -0,0 +1,15 @@
|
|||
#include <stdio.h>
|
||||
#include "mean.h"
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
|
||||
double v1, v2, m;
|
||||
v1 = 5.2;
|
||||
v2 = 7.9;
|
||||
|
||||
m = mean(v1, v2);
|
||||
|
||||
printf("The mean of %3.2f and %3.2f is %3.2f\n", v1, v2, m);
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue