set (Tutorial_VERSION_MAJOR 1)
set (Tutorial_VERSION_MINOR 0)
configure_file (
“ P R O J E C T S O U R C E D I R / T u t o r i a l C o n f i g . h . i n " " {PROJECT_SOURCE_DIR}/TutorialConfig.h.in" " PROJECTSOURCEDIR/TutorialConfig.h.in""{PROJECT_BINARY_DIR}/TutorialConfig.h”
)
include_directories("${PROJECT_BINARY_DIR}")
add_executable(Tutorial_A tutorial.cpp)
// A simple program that computes the square root of a number
#include
#include
#include
// include 了cmake 生成配置文件
#include “TutorialConfig.h”
int main (int argc, char *argv[]) {
if (argc < 2)
{
fprintf(stdout,"%s Version %d.%d\n",
argv[0],
// 使用了 cmake 生成的配置参数
Tutorial_VERSION_MAJOR,
Tutorial_VERSION_MINOR);
fprintf(stdout,“Usage: %s number\n”,argv[0]);
return 1;
}
double inputValue = atof(argv[1]);
double outputValue = sqrt(inputValue);
fprintf(stdout,“The square root of %g is %g\n”,
inputValue, outputValue);
return 0;
}
// 这个是配置文件,cmake 会根据他在 cmake 的 build 目录生成一个 TutorialConfig.h 文件
#define Tutorial_VERSION_MAJOR @Tutorial_VERSION_MAJOR@
#define Tutorial_VERSION_MINOR @Tutorial_VERSION_MINOR
cmake_minimum_required (VERSION 2.6)
add_library(MathFunctions mysqrt.cpp)
#include “MathFunctions.h”
#include
// a hack square root calculation using simple operations
double mysqrt(double x) {
if (x <= 0) {
return 0;
}
double result;
double delta;
result = x;
// do ten iterations
int i;
for (i = 0; i < 10; ++i) {
if (result <= 0) {
result = 0.1;
}
delta = x - (result * result);
result = result + 0.5 * delta / result;
fprintf(stdout, “Computing sqrt of %g to be %g\n”, x, result);
}
return result;
}
//
// Created by 何时夕 on 2018/11/11.
//
#ifndef PROJECT_MATHFUNCTIONS_H
#define PROJECT_MATHFUNCTIONS_H
double mysqrt(double x);
#endif //PROJECT_MATHFUNCTIONS_H
cmake_minimum_required (VERSION 2.6)
project (Tutorial_Mylib)
set (Tutorial_VERSION_MAJOR 1)
set (Tutorial_VERSION_MINOR 0)
configure_file (
“ P R O J E C T S O U R C E D I R / T u t o r i a l C o n f i g . h . i n " " {PROJECT_SOURCE_DIR}/TutorialConfig.h.in" " PROJECTSOURCEDIR/TutorialConfig.h.in""{PROJECT_BINARY_DIR}/TutorialConfig.h”
)
option (USE_MYMATH
“Use tutorial provided math implementation” ON)
configure_file(" P R O J E C T S O U R C E D I R / C o n f i g u r e . h . i n " " {PROJECT_SOURCE_DIR}/Configure.h.in" " PROJECTSOURCEDIR/Configure.h.in""{PROJECT_BINARY_DIR}/Configure.h")
include_directories("${PROJECT_BINARY_DIR}")
if (USE_MYMATH)
include_directories ("${PROJECT_SOURCE_DIR}/mylib")
add_subdirectory (mylib)
set (EXTRA_LIBS MathFunctions)
endif (USE_MYMATH)
add_executable (Tutorial_Mylib tutorial.cpp)
target_link_libraries (Tutorial_Mylib ${EXTRA_LIBS})
#cmakedefine USE_MYMATH
#include
#include
#include
#include “TutorialConfig.h”
#include “Configure.h”
#ifdef USE_MYMATH
#include “MathFunctions.h”
#endif
int main (int argc, char *argv[]) {
if (argc < 2)
{
fprintf(stdout,"%s Version %d.%d\n", argv[0],
Tutorial_VERSION_MAJOR,
Tutorial_VERSION_MINOR);
fprintf(stdout,“Usage: %s number\n”,argv[0]);
return 1;
}
double inputValue = atof(argv[1]);
#ifdef USE_MYMATH
// 如果开关开了,就使用我自己的库
double outputValue = mysqrt(inputValue);
fprintf(stdout,“use my math”);
#else
double outputValue = sqrt(inputValue);
fprintf(stdout,“not use my math”);
#endif
fprintf(stdout,“The square root of %g is %g\n”,
inputValue, outputValue);
return 0;
}
cmake_minimum_required (VERSION 2.6)
add_library(MathFunctions mysqrt.cpp)
#include “MathFunctions.h”
#include
// a hack square root calculation using simple operations
double mysqrt(double x) {
if (x <= 0) {
return 0;
}
double result;
double delta;
result = x;
// do ten iterations
int i;
for (i = 0; i < 10; ++i) {
if (result <= 0) {
result = 0.1;
}
delta = x - (result * result);
result = result + 0.5 * delta / result;
fprintf(stdout, “Computing sqrt of %g to be %g\n”, x, result);
}
return result;
}
//
// Created by 何时夕 on 2018/11/11.
//
#ifndef PROJECT_MATHFUNCTIONS_H
#define PROJECT_MATHFUNCTIONS_H
double mysqrt(double x);
#endif //PROJECT_MATHFUNCTIONS_H
cmake_minimum_required (VERSION 2.6)
project (Tutorial_Mylib)
set (Tutorial_VERSION_MAJOR 1)
set (Tutorial_VERSION_MINOR 0)
configure_file (
“ P R O J E C T S O U R C E D I R / T u t o r i a l C o n f i g . h . i n " " {PROJECT_SOURCE_DIR}/TutorialConfig.h.in" " PROJECTSOURCEDIR/TutorialConfig.h.in""{PROJECT_BINARY_DIR}/TutorialConfig.h”
)
option (USE_MYMATH
“Use tutorial provided math implementation” ON)
configure_file(" P R O J E C T S O U R C E D I R / C o n f i g u r e . h . i n " " {PROJECT_SOURCE_DIR}/Configure.h.in" " PROJECTSOURCEDIR/Configure.h.in""{PROJECT_BINARY_DIR}/Configure.h")
include_directories("${PROJECT_BINARY_DIR}")
if (USE_MYMATH)
include_directories ("${PROJECT_SOURCE_DIR}/mylib")
add_subdirectory (mylib)
set (EXTRA_LIBS MathFunctions)
endif (USE_MYMATH)
add_executable (Tutorial_Mylib tutorial.cpp)
target_link_libraries (Tutorial_Mylib ${EXTRA_LIBS})
#cmakedefine USE_MYMATH
#include
#include
#include
#include “TutorialConfig.h”
#include “Configure.h”
#ifdef USE_MYMATH
#include “MathFunctions.h”
#endif
int main (int argc, char *argv[]) {
if (argc < 2)
{
fprintf(stdout,"%s Version %d.%d\n", argv[0],
Tutorial_VERSION_MAJOR,
Tutorial_VERSION_MINOR);
fprintf(stdout,“Usage: %s number\n”,argv[0]);
return 1;
}
double inputValue = atof(argv[1]);
#ifdef USE_MYMATH
// 如果开关开了,就使用我自己的库
double outputValue = mysqrt(inputValue);
fprintf(stdout,“use my math”);
#else
double outputValue = sqrt(inputValue);
fprintf(stdout,“not use my math”);
#endif
fprintf(stdout,“The square root of %g is %g\n”,
inputValue, outputValue);
return 0;
}
install (TARGETS MathFunctions_Install DESTINATION bin)
install (FILES MathFunctions.h DESTINATION include)
install (TARGETS Tutorial_Mylib_Install DESTINATION bin)
install (FILES “${PROJECT_BINARY_DIR}/TutorialConfig.h”
DESTINATION include)
project(MakeTable)
add_executable(MakeTable MakeTable.cpp)
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/Table.h
COMMAND MakeTable ${CMAKE_CURRENT_BINARY_DIR}/Table.h
DEPENDS MakeTable)
include_directories(${CMAKE_CURRENT_BINARY_DIR})
对我们开发者来说,一定要打好基础,随时准备战斗。不论寒冬是否到来,都要把自己的技术做精做深。虽然目前移动端的招聘量确实变少了,但中高端的职位还是很多的,这说明行业只是变得成熟规范起来了。竞争越激烈,产品质量与留存就变得更加重要,我们进入了技术赋能业务的时代。
不论遇到什么困难,都不应该成为我们放弃的理由!
很多人在刚接触这个行业的时候或者是在遇到瓶颈期的时候,总会遇到一些问题,比如学了一段时间感觉没有方向感,不知道该从那里入手去学习,对此我针对Android程序员,我这边给大家整理了一套学习宝典!包括不限于高级UI、性能优化、移动架构师、NDK、混合式开发(ReactNative+Weex)微信小程序、Flutter等全方面的Android进阶实践技术;希望能帮助到大家,也节省大家在网上搜索资料的时间来学习,也可以分享动态给身边好友一起学习!
Android学习PDF+架构视频+面试文档+源码笔记
【Android核心高级技术PDF文档,BAT大厂面试真题解析】
【算法合集】
【延伸Android必备知识点】
aster/Android%E5%BC%80%E5%8F%91%E4%B8%8D%E4%BC%9A%E8%BF%99%E4%BA%9B%EF%BC%9F%E5%A6%82%E4%BD%95%E9%9D%A2%E8%AF%95%E6%8B%BF%E9%AB%98%E8%96%AA%EF%BC%81.md)
【Android核心高级技术PDF文档,BAT大厂面试真题解析】
[外链图片转存中…(img-v00iXrDJ-1643966678503)]
【算法合集】
[外链图片转存中…(img-8RFPvP1x-1643966678504)]
【延伸Android必备知识点】
[外链图片转存中…(img-Q27WwYcG-1643966678505)]
【Android部分高级架构视频学习资源】