Created
January 13, 2022 20:07
-
-
Save markfinal/18870327dc611a34a937098ccbb76541 to your computer and use it in GitHub Desktop.
No option required for BUILD_SHARED_LIBS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
cmake -GNinja -Bbuild_static . | |
cmake -GNinja -DBUILD_SHARED_LIBS=ON -Bbuild_shared . | |
ninja -C build_static | |
ninja -C build_shared | |
ls -al build_static/*test* | |
ls -al build_shared/*test* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cmake_minimum_required(VERSION 3.21) | |
project(Test LANGUAGES CXX) | |
add_library(test lib.cpp lib.h) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
void a_func() | |
{ | |
std::cout << "Hello" << std::endl; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma once | |
extern void a_func(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- The CXX compiler identification is AppleClang 13.0.0.13000029 | |
-- Detecting CXX compiler ABI info | |
-- Detecting CXX compiler ABI info - done | |
-- Check for working CXX compiler: /Applications/Xcode12.4.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ - skipped | |
-- Detecting CXX compile features | |
-- Detecting CXX compile features - done | |
-- Configuring done | |
-- Generating done | |
-- Build files have been written to: /tmp/test/build_static | |
-- The CXX compiler identification is AppleClang 13.0.0.13000029 | |
-- Detecting CXX compiler ABI info | |
-- Detecting CXX compiler ABI info - done | |
-- Check for working CXX compiler: /Applications/Xcode12.4.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ - skipped | |
-- Detecting CXX compile features | |
-- Detecting CXX compile features - done | |
-- Configuring done | |
-- Generating done | |
-- Build files have been written to: /tmp/test/build_shared | |
ninja: Entering directory `build_static' | |
[1/2] Building CXX object CMakeFiles/test.dir/lib.cpp.o | |
[2/2] Linking CXX static library libtest.a | |
ninja: Entering directory `build_shared' | |
[1/2] Building CXX object CMakeFiles/test.dir/lib.cpp.o | |
[2/2] Linking CXX shared library libtest.dylib | |
-rw-r--r-- 1 mark wheel 14824 13 Jan 20:05 build_static/libtest.a | |
-rwxr-xr-x 1 mark wheel 56168 13 Jan 20:05 build_shared/libtest.dylib |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment