LoginSignup
2
1

More than 5 years have passed since last update.

cmakeでライブラリ名と実行ファイル名を同じにする

Posted at

ライブラリのターゲット名をhoge、実行ファイルのターゲット名をhoge-binとして、実行ファイルの出力名を別途設定する。

以下の様なCMakeList.txtを作る。

FILE(GLOB BASESRCS "src/*.cc")
ADD_LIBRARY(hoge SHARED ${BASESRCS})
ADD_EXECUTABLE(hoge-bin apps/cli.cc)
SET_TARGET_PROPERTIES(hoge-bin PROPERTIES OUTPUT_NAME hoge)
TARGET_LINK_LIBRARIES(hoge-bin hoge)

INSTALL(TARGETS hoge-bin RUNTIME DESTINATION bin)
INSTALL(TARGETS hoge LIBRARY DESTINATION lib)
2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1