Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"CMAKE" - how to produce both ".dll" and ".lib" as ouputs [duplicate]

Tags:

c++

cmake

As a result for my build it is expected to upload on the Artifactory repository both .dll and .lib file. Currently I am getting just .lib.

Can I add something additional to have .dll generated as well as repo expects that?

project(SystemUtils)


find_package(LogMsg REQUIRED)

set(SOURCES
  Eventlog.cpp
  OSObjects.cpp
)

set(HEADERS
  Eventlog.h
  OSObjects.h
  StdAfx.h
)

set(SOURCES
  ${SOURCES}
  ${MAIN_SOURCES}
)

set(HEADERS
  ${HEADERS}
  ${MAIN_HEADERS}
)

if(WIN32)

  set(CMAKE_CXX_FLAGS 
    "${CMAKE_CXX_FLAGS} -EHa -Fd$(OutDir)$(TargetName).pdb"
  )
endif()    

add_library(${PROJECT_NAME} HEADERS SOURCES)


target_include_directories(${PROJECT_NAME}
  PUBLIC .
  PUBLIC ${FALogMsg_INCLUDE_DIRS}
)

target_link_libraries(${PROJECT_NAME})
like image 263
AndreyS Avatar asked Nov 01 '25 16:11

AndreyS


1 Answers

You can use this CMake command in windows platform:

set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)

then the import library(.lib file) for your dll will be generated.

like image 199
Tom Avatar answered Nov 03 '25 09:11

Tom