CMake static library example added.

This commit is contained in:
Kolan Sh 2012-05-22 13:53:04 +04:00
parent b6d6d84dcd
commit 7fa1a0a6d6
6 changed files with 34 additions and 0 deletions

View File

@ -0,0 +1,5 @@
cmake_minimum_required (VERSION 2.6)
project (HELLO)
add_subdirectory (libmean)
add_subdirectory (test)

View File

@ -0,0 +1 @@
add_library (libmean mean.c)

View File

@ -0,0 +1,5 @@
//#include <stdio.h>
double mean(double a, double b) {
return (a+b) / 2;
}

View File

@ -0,0 +1 @@
double mean(double, double);

View File

@ -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)

View File

@ -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;
}