forked from FlyGoat/RyzenAdj
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rework cmake files to allow easier integration with other projects
- Loading branch information
Showing
2 changed files
with
78 additions
and
40 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,27 @@ | ||
#cmake version | ||
CMAKE_MINIMUM_REQUIRED(VERSION 3.9) | ||
CMAKE_MINIMUM_REQUIRED(VERSION 3.23) | ||
|
||
#define project name | ||
PROJECT(ryzenadj) | ||
PROJECT(ryzenadjcli) | ||
|
||
set(CMAKE_C_VISIBILITY_PRESET hidden) | ||
|
||
set(CMAKE_CXX_STANDARD 11) | ||
set(CMAKE_CXX_VISIBILITY_PRESET hidden) | ||
|
||
message(STATUS "Build type: ${CMAKE_BUILD_TYPE}") | ||
add_subdirectory(lib) | ||
|
||
#Enable LTO | ||
include(CheckIPOSupported) | ||
check_ipo_supported(RESULT supported OUTPUT error) | ||
if( supported ) | ||
message(STATUS "IPO / LTO enabled") | ||
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE) | ||
endif() | ||
check_ipo_supported(RESULT has_ipo OUTPUT error) | ||
|
||
INCLUDE_DIRECTORIES(${INC_DIR}) | ||
|
||
AUX_SOURCE_DIRECTORY(./ SRC_DIR) | ||
|
||
if(WIN32) | ||
set(OS_SOURCE lib/osdep_win32.cpp) | ||
set(OS_LINK_LIBRARY WinRing0x64) | ||
set(OS_LINK_DIR ./win32) | ||
else() | ||
set(OS_SOURCE lib/osdep_linux.c) | ||
#if (CMAKE_BUILD_TYPE STREQUAL "Release") | ||
#Static link libpci in release build | ||
#set(OS_LINK_LIBRARY libpci.a) | ||
#else() | ||
set(OS_LINK_LIBRARY pci) | ||
#endif() | ||
endif() | ||
add_executable(${PROJECT_NAME} argparse.c main.c) | ||
|
||
LINK_DIRECTORIES(${OS_LINK_DIR}) | ||
if(has_ipo) | ||
message(STATUS "${PROJECT_NAME}: IPO / LTO enabled") | ||
set_property(TARGET ${PROJECT_NAME} PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE) | ||
endif() | ||
|
||
set(COMMON_SOURCES lib/nb_smu_ops.c lib/api.c lib/cpuid.c) | ||
add_definitions(-D_LIBRYZENADJ_INTERNAL) | ||
if (WIN32) | ||
target_link_directories(${PROJECT_NAME} PRIVATE win32) | ||
endif () | ||
|
||
ADD_EXECUTABLE(${PROJECT_NAME} ${OS_SOURCE} ${COMMON_SOURCES} argparse.c main.c) | ||
target_link_libraries(${PROJECT_NAME} ${OS_LINK_LIBRARY}) | ||
#SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES LINKER_LANGUAGE C) | ||
option(BUILD_SHARED_LIBS "Build using shared libraries" ON) | ||
ADD_LIBRARY (libryzenadj ${OS_SOURCE} ${COMMON_SOURCES}) | ||
set_target_properties(libryzenadj PROPERTIES PREFIX "") | ||
target_link_libraries(libryzenadj ${OS_LINK_LIBRARY}) | ||
#SET_TARGET_PROPERTIES(libryzenadj PROPERTIES LINKER_LANGUAGE C) | ||
include(GNUInstallDirs) | ||
target_link_libraries(${PROJECT_NAME} RYADJ::RyzenAdjLib) | ||
install(TARGETS ${PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR}) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
CMAKE_MINIMUM_REQUIRED(VERSION 3.23) | ||
|
||
project(ryzenadj) | ||
|
||
option(BUILD_SHARED_LIBS "Build using shared libraries" ON) | ||
|
||
include(CheckIPOSupported) | ||
check_ipo_supported(RESULT has_ipo OUTPUT error) | ||
|
||
set(PROJECT_SOURCES | ||
nb_smu_ops.c | ||
api.c | ||
cpuid.c | ||
) | ||
|
||
set(PUB_HEADERS | ||
ryzenadj.h | ||
) | ||
|
||
if (WIN32) | ||
set(LINK_LIBS WinRing0x64) | ||
|
||
list(APPEND PROJECT_SOURCES | ||
osdep_win32.cpp | ||
) | ||
|
||
elseif (LINUX) | ||
set(LINK_LIBS pci) | ||
|
||
list(APPEND PROJECT_SOURCES | ||
osdep_linux.c | ||
) | ||
|
||
else () | ||
message(FATAL_ERROR "!Unsupported OS!") | ||
endif () | ||
|
||
add_library(${PROJECT_NAME} ${PUB_HEADERS} ${PROJECT_SOURCES}) | ||
add_library("RYADJ::RyzenAdjLib" ALIAS ${PROJECT_NAME}) | ||
|
||
if(has_ipo) | ||
message(STATUS "${PROJECT_NAME}: IPO / LTO enabled") | ||
set_property(TARGET ${PROJECT_NAME} PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE) | ||
endif() | ||
|
||
if (WIN32) | ||
target_link_directories(${PROJECT_NAME} PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/../win32") | ||
endif () | ||
|
||
target_compile_definitions(${PROJECT_NAME} PUBLIC _LIBRYZENADJ_INTERNAL) | ||
target_link_libraries(${PROJECT_NAME} ${LINK_LIBS}) | ||
|
||
target_sources(${PROJECT_NAME} PUBLIC | ||
FILE_SET rylib_headers | ||
TYPE HEADERS | ||
FILES ${PUB_HEADERS} | ||
) | ||
|
||
include(GNUInstallDirs) | ||
install(TARGETS ${PROJECT_NAME} | ||
FILE_SET rylib_headers DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME} | ||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} | ||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} | ||
) |