cmake in-source build&…

本文详细解释了in-source与out-of-source构建方式的区别,包括它们各自的优势、应用场景以及如何在实际项目中应用。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

比如下面的工程目录

/home/username/hello.cpp
/home/username/CMakeLists.txt

所谓in-source build就是在/home/username/目录下执行cmake . (注意最后一个点表示当前目录)
这样会在/home/username/下出现很多临时文件


所谓out-of-source build就是在/home/username/下新建目录bin/
然后在/home/username/bin中执行 cmake .. (注意最后是两个点 表示上一个目录)
这样所有临时文件和最后结果都会出现在/home/username/bin中, 源代码目录中比较清爽
# Dockerfile to build OpenSees, OpenSeesSP and OpenSeesMP # .. utilizes ubuntu:20.04 LTS as base # .. it will build all applications and place in /usr/local/bin # .. it will also install openmpi # .. to run OpenSeesSP and OpenSeesMP use mpiexec, e.g. mpiexec -n 2 OpenSeesSP example.tcl # written: fmk FROM ubuntu:20.04 SHELL ["/bin/bash", "-c"] WORKDIR /opensees RUN cp /etc/apt/sources.list /etc/apt/sources.list~ \ && sed -Ei 's/^# deb-src /deb-src /' /etc/apt/sources.list \ && apt-get update \ && DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC apt-get -y install tzdata git \ && apt-get install -y sudo \ && sudo apt-get install -y cmake gcc g++ gfortran liblapack-dev git python3-pip \ && sudo apt-get install -y openmpi-bin openmpi-common libopenmpi-dev libscalapack-openmpi-dev \ && pip3 install conan==1.60.1 \ && git clone --depth 1 --branch hdf5-1_12_2 https://github.com/HDFGroup/hdf5.git \ && cd hdf5 \ && ./configure --prefix=/usr/local/hdf5 \ && make \ && cd .. \ && git clone https://github.com/OpenSees/mumps.git \ && cd mumps \ && mkdir build \ && cd build \ && cmake .. -Darith=d \ && cmake --build . \ && cd ../.. \ && git clone https://github.com/OpenSees/OpenSees.git \ && cd OpenSees \ && mkdir build \ && cd build \ && conan install .. --build missing \ && cmake .. -DMUMPS_DIR=$PWD/../../mumps/build -DOPENMPI=TRUE -DSCALAPACK_LIBRARIES="/usr/lib/x86_64-linux-gnu/libscalapack-openmpi.so.2.1" \ && cmake --build . --config Release --target OpenSees \ && cmake --build . --config Release --target OpenSeesSP \ && cmake --build . --config Release --target OpenSeesMP \ && cp ./bin/* /usr/local/bin \ && cp -r ./lib/tcl8.6 /usr/local/lib \ && cd ../.. \ && rm -fr OpenSees \ && rm -fr hdf5 \ && rm -fr mumps # Dockerfile to build OpenSees, OpenSeesSP and OpenSeesMP # .. utilizes ubuntu:20.04 LTS as base # .. it will build all applications and place in /usr/local/bin # .. it will also install openmpi # .. to run OpenSeesSP and OpenSeesMP use mpiexec, e.g. mpiexec -n 2 OpenSeesSP example.tcl # written: fmk FROM ubuntu:20.04 SHELL ["/bin/bash", "-c"] WORKDIR /opensees RUN cp /etc/apt/sources.list /etc/apt/sources.list~ \ && sed -Ei 's/^# deb-src /deb-src /' /etc/apt/sources.list \ && apt-get update \ && DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC apt-get -y install tzdata git \ && apt-get install -y sudo \ && sudo apt-get install -y cmake gcc g++ gfortran liblapack-dev git python3-pip \ && sudo apt-get install -y openmpi-bin openmpi-common libopenmpi-dev libscalapack-openmpi-dev \ && pip3 install conan==1.60.1 \ && git clone --depth 1 --branch hdf5-1_12_2 https://github.com/HDFGroup/hdf5.git \ && cd hdf5 \ && ./configure --prefix=/usr/local/hdf5 \ && make \ && cd .. \ && git clone https://github.com/OpenSees/mumps.git \ && cd mumps \ && mkdir build \ && cd build \ && cmake .. -Darith=d \ && cmake --build . \ && cd ../.. \ && git clone https://github.com/OpenSees/OpenSees.git \ && cd OpenSees \ && mkdir build \ && cd build \ && conan install .. --build missing \ && cmake .. -DMUMPS_DIR=$PWD/../../mumps/build -DOPENMPI=TRUE -DSCALAPACK_LIBRARIES="/usr/lib/x86_64-linux-gnu/libscalapack-openmpi.so.2.1" \ && cmake --build . --config Release --target OpenSees \ && cmake --build . --config Release --target OpenSeesSP \ && cmake --build . --config Release --target OpenSeesMP \ && cp ./bin/* /usr/local/bin \ && cp -r ./lib/tcl8.6 /usr/local/lib \ && cd ../.. \ && rm -fr OpenSees \ && rm -fr hdf5 \ && rm -fr mumps
最新发布
03-09
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值